jedisct1 / encpipe

The dum^H^H^Hsimplest encryption tool in the world.
Other
210 stars 13 forks source link

Passing CFLAGS and LDFLAGS #6

Closed kpcyrd closed 1 year ago

kpcyrd commented 2 years ago

hi!

I've packaged encpipe for Arch, building the binary like this:

make bin

gives me this warning:

encpipe W: ELF file ('usr/bin/encpipe') lacks FULL RELRO, check LDFLAGS.

In the makefile I noticed that CFLAGS is being set unless passed explicitly, so I tried this:

make CFLAGS="${CFLAGS}" bin

compile fails with:

In file included from src/encpipe.c:1:
src/encpipe_p.h:19:10: fatal error: hydrogen.h: No such file or directory
   19 | #include <hydrogen.h>
      |          ^~~~~~~~~~~~

Next up I tried this:

make CFLAGS="${CFLAGS} -Iext/libhydrogen" bin

which compiles again, but same warning:

encpipe W: ELF file ('usr/bin/encpipe') lacks FULL RELRO, check LDFLAGS.

Lastly I tried this:

make CFLAGS="${CFLAGS} -Iext/libhydrogen ${LDFLAGS}" bin

which works and resulted in a FULL RELRO binary, but I'm not sure if it's the correct thing to do:

$ checksec --file=usr/bin/encpipe 
RELRO           STACK CANARY      NX            PIE             RPATH      RUNPATH  Symbols     FORTIFY Fortified   Fortifiable FILE
Full RELRO      Canary found      NX enabled    PIE enabled     No RPATH   No RUNPATH   No Symbols    No    0   6usr/bin/encpipe

Do you have any hints what's the correct way to pass CFLAGS and LDFLAGS for this project?

Thanks!

jedisct1 commented 2 years ago

Hi!

The Makefile was updated to let you override CFLAGS (without requiring the additional -I...) and LDFLAGS.

Does that work for you?

I can also add a Zig build file, so that it's easy to cross compile to any architecture.

waldyrious commented 2 years ago

The Makefile was updated to let you override CFLAGS (without requiring the additional -I...) and LDFLAGS.

For future reference, that was commit f278117be2e5ee563813df83e1f22fd567461d4e.

jedisct1 commented 2 years ago

So, does that work for you? If you need any other changes to be made, just lemme know :)

kpcyrd commented 2 years ago

Thanks, with that patch make bin works nicely! :)

btw the package is currently using a git clone instead of tar balls because in the github generated tar ball is missing the libhydrogen submodule.