[ACCEPTED]-Passing a gcc flag through makefile-llvm
Looks like you could add the -fPIC (for 11 position-independent code, something you 10 want for a shared library that could be 9 loaded at any address) by setting shell 8 variables:
export CFLAGS="$CFLAGS -fPIC"
export CXXFLAGS="$CXXFLAGS -fPIC"
Looking at Makefile.rules, these will be picked 7 up and used. Seems strange that it wasn't 6 there to begin with.
EDIT:
Actually, reading 5 more in the makefiles, I found this link 4 to the LLVM Makefile Guide. From Makefile.rules, setting either 3 SHARED_LIBRARY=1 or LOADABLE_MODULE=1 (which 2 implies SHARED_LIBRARY) in Makefile will 1 put -fPIC in the compiler flags.
If you are moderately convinced that you 13 should use '-fPIC
' everywhere (or '-m32
' or '-m64
', which 12 I need more frequently), then you can use 11 the 'trick':
CC="gcc -fPIC" ./configure ...
This assumes a Bourne/Korn/POSIX/Bash 10 shell and sets the environment variable 9 CC to 'gcc -fPIC
' before running the configure script. This 8 (usually) ensures that all compilations 7 are done with the specified flags. For 6 setting the correct 'bittiness' of the compilation, this 5 sometimes works better than the various 4 other mechanisms you find - it is hard for 3 a compilation to wriggle around it except 2 by completely ignoring the fact you specified 1 the C compiler to use.
Another option is to pass -fPIC directly 1 to make in the following way:
make CFLAGS='-fPIC' CXXFLAGS='-fPIC'
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.