eclipse-omr / omr

Eclipse OMR™ Cross platform components for building reliable, high performance language runtimes
http://www.eclipse.org/omr
Other
950 stars 397 forks source link

Compiling jitbuilder with CMAKE in debug mode omits -fPIC #1626

Closed tajila closed 7 years ago

tajila commented 7 years ago

When compiler jitbuilder with the default configuration omr/jitbuilder $ make -j16 the output is:

g++ -std=c++0x -fno-rtti -fno-threadsafe-statics -Wno-deprecated -Wno-enum-compare -Wno-invalid-offsetof -Wno-write-strings -O3 -pthread -fomit-frame-pointer -fasynchronous-unwind-tables -Wreturn-type -fno-dollars-in-identifiers -m64-fPIC-fno-strict-aliasing -DBITVECTOR_BIT_NUMBERING_MSB -DUT_DIRECT_TRACE_REGISTRATION -DJITTEST -DJITBUILDER_SPECIFIC -DPROD_WITH_ASSUMES -DTR_HOST_X86 -DTR_HOST_64BIT -DBITVECTOR_64BIT -DLINUX -DTR_TARGET_X86 -DTR_TARGET_64BIT -DSUPPORTS_THREAD_LOCAL -D_LONG_LONG -DJ9HAMMER -I'../include_core' -I'../jitbuilder/x/amd64' -I'../jitbuilder/x' -I'../jitbuilder' -I'../compiler/x/amd64' -I'../compiler/x' -I'../compiler' -I'..' -MMD -MF ../build/compiler/compile/OSRData.o.depend.mk -MT ../build/compiler/compile/OSRData.o -MP -o ../build/compiler/compile/OSRData.o -c ../compiler/compile/OSRData.cpp

...

When using CMAKE with omr/debug $ cmake -C ../cmake/caches/Travis.cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug .. && export VERBOSE=1 && make jitbuilder the output is:

[ 4%] Building CXX object jitbuilder/CMakeFiles/jitbuilder.dir/env/FrontEnd.cpp.o cd <snip>/omr/debug/jitbuilder && /bluebird/bin/platform/linux_hammer/ccache/c++ -DBITVECTOR_BIT_NUMBERING_MSB -DJ9HAMMER -DLINUX -DPROD_WITH_ASSUMES -DSUPPORTS_THREAD_LOCAL -DTR_HOST_64BIT -DTR_HOST_X86 -DTR_TARGET_64BIT -DTR_TARGET_X86 -DUT_DIRECT_TRACE_REGISTRATION -D_FILE_OFFSET_BITS=64 -I<snip>/omr/jitbuilder/x/amd64 -I<snip>/omr/jitbuilder/x -I<snip>/omr/jitbuilder -I<snip>/omr/compiler/x/amd64 -I<snip>/omr/compiler/x -I<snip>/omr/compiler -I<snip>/omr -I<snip>/omr/debug -I<snip>/omr/./include -I<snip>/omr/./include_core -I<snip>/omr/./third_party -pthread -g -std=c++0x -Wno-write-strings -o CMakeFiles/jitbuilder.dir/env/FrontEnd.cpp.o -c <snip>/omr/jitbuilder/env/FrontEnd.cpp

dnakamura commented 7 years ago

Yes the issue is that CMake will only apply -fPIC when it thinks it needs to, (although it isnt particularly smart about it). In the mean time you can work arround the issue by specifying -DCMAKE_POSITION_INDEPENDENT_CODE=ON when invoking cmake

@rwy0717 does it make sense to enable -fPIC globally, or just on the targets we care about?

rwy7 commented 7 years ago

It probably makes sense to enable PIC code everywhere. How about we set CMAKE_POSITION_INDEPENDENT_CODE to ON in the root of OMR?