facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.19k stars 3k forks source link

Compilation: linking fails on undefined reference to HPHP::hash_string_i_unsafe #7503

Open calimeroteknik opened 7 years ago

calimeroteknik commented 7 years ago

HHVM Version

4a28740

Standalone code, or other way to reproduce the problem

Building on gentoo stable (up-to-date as of 2016-11-20)

Expected result

A successful linking phase

Actual result

Linking fails, the first error is (formatting added): ../compiler/libhphp_analysis.a(option.cpp.o):option.cpp:function std::__detail::_Map_base<std::string, std::pair<std::string const, std::string>, std::allocator<std::pair<std::string const, std::string> >, std::__detail::_Select1st, HPHP::stringlike_eqstri<std::string, std::string>, HPHP::string_hashi, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true>, true>::operator[](std::string const&):error: undefined reference to 'HPHP::hash_string_i_unsafe(char const*, unsigned int)'

Complete end of the compilation: hhvm-compile-log.txt

aorenste commented 7 years ago

Are you passing any compilation options to cmake or make? Also what type of architecture are you compiling for? Those functions are controlled by USE_SSECRC, NOSSECRC and \_SSE4_2__ so it's possible there's a mismatch somehow.

calimeroteknik commented 7 years ago

I use the following environment on hardened gentoo (ASLR and PIE executables except hhvm): CFLAGS="-march=sandybridge -O2 -pipe" CXXFLAGS="-march=sandybridge -O2 -pipe -nopie" CHOST="x86_64-pc-linux-gnu" LDFLAGS="-Wl,-O1 -Wl,--as-needed -nopie" MAKEOPTS="-j4"

None of the variables you mentioned appear anywhere. HHVM was building and working fine when I built it on Sat Nov 5 15:34:04 2016

The following commands were used both times: ./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --locals tatedir=/var/lib --libdir=/usr/lib64 -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release make -j4

[EDIT] full build log attached with commands, built today with 5a04b17: hhvm-build.txt

calimeroteknik commented 7 years ago

No change with 6271def

usox commented 7 years ago

I can confirm this compilation issue on gentoo at least since 3.17.3.

usox commented 7 years ago

@calimeroteknik -march=sandybridge and -march=native (in my case) enable SSE42 support, so maybe its actual related.

usox commented 7 years ago

@aorenste It definitly depends on the cflags.

Using -march with a sse4.2 capable option (like ivybridge) fails with the known errors.

./configure -DCMAKE_C_FLAGS="-O2 -pipe -march=ivybridge" -DCMAKE_CXX_FLAGS="-O2 -pipe -march=ivybridge" -DCMAKE_INSTALL_PREFIX="/usr" -DCMAKE_BUILD_TYPE="Release"
make -j6

Using a more generic approach works as expected

./configure -DCMAKE_C_FLAGS="-O2 -pipe -march=core2" -DCMAKE_CXX_FLAGS="-O2 -pipe -march=core2" -DCMAKE_INSTALL_PREFIX="/usr" -DCMAKE_BUILD_TYPE="Release"
make -j6

Maybe, this is related to e3a78d7611f658105ca4e48facf6673880311973. I'll dig into the code a bit, but I'm no c++-ninja ;)

katekyan commented 7 years ago

Using -march=Skylake or -mavx512f or -mavx512cd fails with the error as well.

ghost commented 7 years ago

You have to use CMAKE_ASM_FLAGS as well.

katekyan commented 7 years ago

With CMAKE_ASM_FLAGS in addition, hhvm is built successfully. Thanks!