Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker error for osrm-datastore target when using mason #3501

Closed
Gubio opened this issue Dec 28, 2016 · 10 comments
Closed

Linker error for osrm-datastore target when using mason #3501

Gubio opened this issue Dec 28, 2016 · 10 comments

Comments

@Gubio
Copy link

Gubio commented Dec 28, 2016

Ubuntu 16.04
t2.micro AWS
swap 1gb

-- Enabling mason
-- Building on a 64 bit system
-- Using GNU gold as linker.
-- No build type specified, defaulting to Release
-- Configuring OSRM in release mode
-- Configuring release mode optimizations
-- LTO working
-- Using GCC specific binutils for LTO:
--  /usr/bin/gcc-ar
--  /usr/bin/gcc-ranlib
CMake Warning at CMakeLists.txt:276 (message):
  ENABLE_MASON and ENABLE_LTO/ENABLE_GOLD_LINKER may not work on all linux
  systems currently


CMake Warning at CMakeLists.txt:277 (message):
  For more details see:
  https://github.com/Project-OSRM/osrm-backend/issues/3202


-- Setting linker optimizations
-- Installing dependencies via mason
-- OpenMP support found. Linking just in case for stxxl
-- Configuring done
-- Generating done
-- Build files have been written to: /var/app/osrm-backend/build
[ 30%] Built target EXTRACTOR
[ 30%] Configuring revision fingerprint
-- Fingerprint unchanged, not regenerating
[ 30%] Built target FingerPrintConfigure
[ 42%] Built target UTIL
[ 46%] Built target osrm_extract
[ 65%] Built target ENGINE
[ 69%] Built target STORAGE
[ 73%] Built target osrm
[ 73%] Built target osrm_store
[ 73%] Linking CXX executable osrm-datastore
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(cmdline.o):libs/program_options/src/cmdline.cpp:function boost::program_options::detail::cmdline::run(): error: undefined reference to 'boost::program_options::basic_option<char>::~basic_option()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(cmdline.o):libs/program_options/src/cmdline.cpp:function boost::program_options::detail::cmdline::run(): error: undefined reference to 'boost::program_options::basic_option<char>::basic_option(boost::program_options::basic_option<char> const&)'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(cmdline.o):libs/program_options/src/cmdline.cpp:function boost::program_options::detail::cmdline::run(): error: undefined reference to 'boost::program_options::basic_option<char>::~basic_option()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(cmdline.o):libs/program_options/src/cmdline.cpp:function boost::program_options::detail::cmdline::run(): error: undefined reference to 'boost::program_options::basic_option<char>::basic_option(boost::program_options::basic_option<char> const&)'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(cmdline.o):libs/program_options/src/cmdline.cpp:function boost::program_options::detail::cmdline::run(): error: undefined reference to 'boost::program_options::basic_option<char>::~basic_option()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(cmdline.o):libs/program_options/src/cmdline.cpp:function boost::program_options::detail::cmdline::run(): error: undefined reference to 'boost::program_options::basic_option<char>::~basic_option()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(cmdline.o):libs/program_options/src/cmdline.cpp:function boost::program_options::detail::cmdline::run(): error: undefined reference to 'boost::program_options::basic_option<char>::basic_option(boost::program_options::basic_option<char> const&)'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(cmdline.o):libs/program_options/src/cmdline.cpp:function boost::program_options::detail::cmdline::parse_long_option(std::vector<std::string, std::allocator<std::string> >&): error: undefined reference to 'boost::program_options::basic_option<char>::basic_option(boost::program_options::basic_option<char> const&)'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(options_description.o):libs/program_options/src/options_description.cpp:function boost::detail::shared_count::shared_count<boost::program_options::options_description>(boost::program_options::options_description*): error: undefined reference to 'boost::program_options::options_description::~options_description()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(options_description.o):libs/program_options/src/options_description.cpp:function boost::detail::sp_counted_impl_p<boost::program_options::options_description>::dispose(): error: undefined reference to 'boost::program_options::options_description::~options_description()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(variables_map.o):libs/program_options/src/variables_map.cpp:function boost::program_options::variables_map::get(std::string const&) const: error: undefined reference to 'boost::program_options::variable_value::~variable_value()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(value_semantic.o):libs/program_options/src/value_semantic.cpp:function boost::program_options::invalid_option_value::invalid_option_value(std::string const&): error: undefined reference to 'boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::string const&, std::string const&, int)'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(value_semantic.o):libs/program_options/src/value_semantic.cpp:function boost::program_options::invalid_option_value::invalid_option_value(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&): error: undefined reference to 'boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::string const&, std::string const&, int)'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(value_semantic.o):libs/program_options/src/value_semantic.cpp:function boost::program_options::invalid_bool_value::invalid_bool_value(std::string const&): error: undefined reference to 'boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::string const&, std::string const&, int)'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(value_semantic.o):libs/program_options/src/value_semantic.cpp:function std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const& boost::program_options::validators::get_single_string<wchar_t>(std::vector<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::allocator<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > const&, bool): error: undefined reference to 'boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::string const&, std::string const&, int)'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(value_semantic.o):libs/program_options/src/value_semantic.cpp:vtable for boost::program_options::value_semantic_codecvt_helper<char>: error: undefined reference to 'boost::program_options::value_semantic::~value_semantic()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(value_semantic.o):libs/program_options/src/value_semantic.cpp:vtable for boost::program_options::untyped_value: error: undefined reference to 'boost::program_options::value_semantic::~value_semantic()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(value_semantic.o):libs/program_options/src/value_semantic.cpp:vtable for boost::program_options::value_semantic_codecvt_helper<wchar_t>: error: undefined reference to 'boost::program_options::value_semantic::~value_semantic()'
../mason_packages/linux-x86_64/boost_libprogram_options/1.61.0/lib/libboost_program_options.a(value_semantic.o):libs/program_options/src/value_semantic.cpp:vtable for boost::any::holder<bool>: error: undefined reference to 'boost::any::placeholder::~placeholder()'
collect2: error: ld returned 1 exit status
CMakeFiles/osrm-datastore.dir/build.make:125: recipe for target 'osrm-datastore' failed
make[2]: *** [osrm-datastore] Error 1
CMakeFiles/Makefile2:177: recipe for target 'CMakeFiles/osrm-datastore.dir/all' failed
make[1]: *** [CMakeFiles/osrm-datastore.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

@daniel-j-h daniel-j-h changed the title osrm-datastore fail Linker error for osrm-datastore target when using mason Dec 28, 2016
@daniel-j-h
Copy link
Member

Thanks for reporting. From what I can see you're using the mason integration? Can you reproduce without mason? Ubuntu 16.04 has all dependencies in apt.

I will have a look at this after the holidays. Sidenote: t2.micro has 1 GB of RAM, with only 1 GB of additional swapfile I'm surprised you are able to compile and link at all. If all you need are pre-built binaries you can get them bundled via the npm osrm package.

@acrosson
Copy link

I'm getting the same error. Ubuntu 16.04, plenty of memory (64GB).

@acrosson
Copy link

I got it to work just using the standard build.

mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install

@Gubio
Copy link
Author

Gubio commented Dec 29, 2016

mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .

[ 20%] Building CXX object CMakeFiles/ENGINE.dir/src/engine/plugins/match.cpp.o
[ 20%] Built target ENGINE
Scanning dependencies of target CONTRACTOR
[ 20%] Building CXX object CMakeFiles/CONTRACTOR.dir/src/contractor/contractor.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
CMakeFiles/CONTRACTOR.dir/build.make:62: recipe for target 'CMakeFiles/CONTRACTOR.dir/src/contractor/contractor.cpp.o' failed
make[2]: *** [CMakeFiles/CONTRACTOR.dir/src/contractor/contractor.cpp.o] Error 4
CMakeFiles/Makefile2:327: recipe for target 'CMakeFiles/CONTRACTOR.dir/all' failed
make[1]: *** [CMakeFiles/CONTRACTOR.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

@Gubio
Copy link
Author

Gubio commented Dec 29, 2016

ubuntu@ip-172-31-26-23:/var/app/osrm-backend/build$ sudo cmake --build . --target install
[ 20%] Built target ENGINE
[ 20%] Building CXX object CMakeFiles/CONTRACTOR.dir/src/contractor/contractor.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
CMakeFiles/CONTRACTOR.dir/build.make:62: recipe for target 'CMakeFiles/CONTRACTOR.dir/src/contractor/contractor.cpp.o' failed
make[2]: *** [CMakeFiles/CONTRACTOR.dir/src/contractor/contractor.cpp.o] Error 4
CMakeFiles/Makefile2:327: recipe for target 'CMakeFiles/CONTRACTOR.dir/all' failed
make[1]: *** [CMakeFiles/CONTRACTOR.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

@danpat
Copy link
Member

danpat commented Dec 30, 2016

@Gubio The error you're getting here c++: internal compiler error: Killed (program cc1plus) probably means that the compiler has run out of memory (the Linux kernel out-of-memory killer has killed the cc1plus compiler program).

Can you try building on a machine with more RAM, or adding swap space to the machine you're using?

@daniel-j-h
Copy link
Member

Trying to reproduce the issues. Following the Mason docs

https://github.com/Project-OSRM/osrm-backend/wiki/Building-with-Mason

I get Clang to segfault during linking

[100%] Linking CXX executable osrm-routed
clang-3.9: error: unable to execute command: Segmentation fault (core dumped)
clang-3.9: error: linker command failed due to signal (use -v to see invocation)
[  961.898775] ld.gold[13273]: segfault at 0 ip 00007fa8ccfa1830 sp 00007fffba181d10 error 4 in LLVMgold.so[7fa8cc7e9000+137b000]

Seems like LTO related and can be worked around by passing -DENABLE_LTO=Off.

@Gubio
Copy link
Author

Gubio commented Jan 2, 2017

Done ;)

@Gubio Gubio closed this as completed Jan 2, 2017
@daniel-j-h
Copy link
Member

Follow-up here. I can re-produce your initial issue with the following setup:

  • Use mason but do not install clang via mason (installing clang was missing in the docs)
  • CMake picks up Mason provided deps. but the system's gcc compiler
  • LTO is enabled by default which means gcc emits its own intermediate representation which does not link with the mason provided Clang-based object files

If you add -DENABLE_LTO=Off this setup works, too.

I just re-worked our Wiki and split off the two ways of getting the required dependencies:

And we really should think about disabling LTO by default .. cc @springmeyer @TheMarex

@springmeyer
Copy link
Contributor

we really should think about disabling LTO by default

Huge 👍 I think disabling LTO by default is the right choice.

Use mason but do not install clang via mason (installing clang was missing in the docs)

The bug is in clang 3.9.0 (and causes binutils gold to segfault). It has nothing to do with mason. The clang bug is fixed in 3.9.1 and 4.x and was never present in 3.8.x. This is noted at #3389.

daniel-j-h added a commit that referenced this issue Jan 5, 2017
This disables the `-flto` LTO flag by default since we're seeing
segfaults in compiler lto plugins, binutils and linker errors again and
again for various clang / gcc / binutils combinations.

Pass `-DNEBALE_LTO` to `cmake` in order to re-enable LTO.

LTO situation in short:
- LTO does not work at all for gcc<4.9
- With gcc>=4.9 the "slim" LTO format is getting used dumping IR
- Older binutils need LTO plugins which know how to read this IR
- Recent binutils handle this format all by themselves
- LLVM is more or less the same with some Clang versions segfaulting

If you need the performance benefit of LTO, make sure your compiler and
binutils are up to date and see for yourself if LTO builds work for you.

References:
- https://gcc.gnu.org/wiki/LinkTimeOptimizationFAQ
- #3481 (comment)
- #3501
- #3441

(and a ton of other LTO tickets if you search for them)
daniel-j-h added a commit that referenced this issue Jan 6, 2017
This disables the `-flto` LTO flag by default since we're seeing
segfaults in compiler lto plugins, binutils and linker errors again and
again for various clang / gcc / binutils combinations.

Pass `-DNEBALE_LTO` to `cmake` in order to re-enable LTO.

LTO situation in short:
- LTO does not work at all for gcc<4.9
- With gcc>=4.9 the "slim" LTO format is getting used dumping IR
- Older binutils need LTO plugins which know how to read this IR
- Recent binutils handle this format all by themselves
- LLVM is more or less the same with some Clang versions segfaulting

If you need the performance benefit of LTO, make sure your compiler and
binutils are up to date and see for yourself if LTO builds work for you.

References:
- https://gcc.gnu.org/wiki/LinkTimeOptimizationFAQ
- #3481 (comment)
- #3501
- #3441

(and a ton of other LTO tickets if you search for them)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants