[PATCH] LibTomCrypt on amd64 and -fPIC

shellreef at gmail.com shellreef at gmail.com
Thu Aug 25 02:18:19 GMT 2005


Tom, (also sending to freebsd-amd64 mailing list)

I am on this platform:

FreeBSD 5.4-STABLE FreeBSD 5.4-STABLE #0: Sat Aug 20 13:42:23 PDT 2005  amd64

and received this error message when linking to LibTomCrypt:

ld: /usr/local/lib/libtomcrypt.a(aes.o): relocation R_X86_64_32S can not be
used when making a shared object; recompile with -fPIC

So I recompiled with -fPIC, and it worked as expected. Would it be a
good idea to add -fPIC to CFLAGS in the gcc makefile in the main LTC
distribution? The gcc info page says that -fPIC emits
position-independent code "if supported for the target machine", so if
I'm reading it correctly, it seems that adding this option shouldn't
affect platforms that don't support -fPIC.

An alternative would be to add a patch in the FreeBSD Ports Tree, if
it is not acceptable to add -fPIC to the mainline LibTomCrypt
distribution (patch attached).

http://64.233.187.104/search?q=cache:rXPUY4O_QlgJ:pvrguide.no-ip.com/bbs-old/viewtopic/12079.html+R_X86_64_32S+can+not+be+used+when+making+a+shared+object&hl=en&start=2D
 suggests adding CFLAGS=-fPIC to /etc/make.conf so it is used
system-wide:

>AFAIK, AMD64 pretty much across the board requires you to inject -fPIC
>into every compilation. Probably wouldn't be a bad thing to add to the
>build system.

To FreeBSD-amd64: Can we add -fPIC to make.conf? Are there any
side-effects? (I'd prefer this as I use packages and would prefer to
not compile from ports.)

To Tom: Would you accept this patch into LTC or should it be an
OS-specific patch?

Thanks,
-Jeff Connelly

==ltc.patch (apply in /usr/ports/security/libtomcrypt/work/*/) ==
--- makefile.orig       Wed Aug 24 17:39:15 2005
+++ makefile    Wed Aug 24 17:39:36 2005
@@ -15,7 +15,7 @@
  #ARFLAGS=r
 
  # Compilation flags. Note the += does not write over the user's CFLAGS!
-CFLAGS += -c -I./testprof/ -I./src/headers/ -Wall -Wsign-compare -W
-Wshadow -Wno-unused-parameter -DLTC_SOURCE
+CFLAGS += -c -I./testprof/ -I./src/headers/ -Wall -Wsign-compare -W
-Wshadow -Wno-unused-parameter -DLTC_SOURCE -fPIC
 
  # additional warnings (newer GCC 3.4 and higher)
  #CFLAGS += -Wsystem-headers -Wdeclaration-after-statement
-Wbad-function-cast -Wcast-align -Wstrict-prototypes
-Wmissing-prototypes \


More information about the freebsd-amd64 mailing list