Date: Tue, 5 Dec 2017 13:36:36 -0800 From: Mark Millard <markmi@dsl-only.net> To: Roman Divacky <rdivacky@vlakno.cz> Cc: FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>, FreeBSD Ports <freebsd-ports@freebsd.org> Subject: Re: 32-bit powerpc system-clang based builds of devel/llvm40 and devel/llvm50: fails via "Host compiler appears to require libatomic, but cannot find it" Message-ID: <92AC463A-4A91-4DC2-8536-1026DD5212B6@dsl-only.net> In-Reply-To: <20171205203932.GA53800@vlakno.cz> References: <C4699D3D-56E0-4678-89D7-0725117A622C@dsl-only.net> <20171205203932.GA53800@vlakno.cz>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2017-Dec-5, at 12:39 PM, Roman Divacky <rdivacky at vlakno.cz> wrote: > The cmake test just tries to compile: >=20 > #include <atomic> > std::atomic<int> x; > int main() { > return x; > } >=20 > What happens if you try to compile this small code with your host = compiler? >=20 > Roman [I later show that it seems to be testing with: std::atomic<uint64_t> x (0) instead and is also using a line the example does not have (devel/llvm50 example): uint64_t i =3D x.load(std::memory_order_relaxed); .] # uname -apKU FreeBSD FBSDG4S 12.0-CURRENT FreeBSD 12.0-CURRENT r326192M powerpc = powerpc 1200054 1200054 # more cpp_atomic.cpp=20 #include <atomic> std::atomic<int> x; int main() { return x; } # clang++ -v cpp_atomic.cpp FreeBSD clang version 5.0.0 (tags/RELEASE_500/final 312559) (based on = LLVM 5.0.0svn) Target: powerpc-unknown-freebsd12.0 Thread model: posix InstalledDir: /usr/bin "/usr/bin/clang++" -cc1 -triple powerpc-unknown-freebsd12.0 -emit-obj = -mrelax-all -disable-free -main-file-name cpp_atomic.cpp = -mrelocation-model static -mthread-model posix -mdisable-fp-elim = -masm-verbose -mconstructor-aliases -target-cpu ppc -mfloat-abi hard -v = -dwarf-column-info -debugger-tuning=3Dgdb -resource-dir = /usr/lib/clang/5.0.0 -internal-isystem /usr/include/c++/v1 = -fdeprecated-macro -fdebug-compilation-dir /root/c_tests -ferror-limit = 19 -fmessage-length 200 -fno-signed-char -fobjc-runtime=3Dgnustep = -fcxx-exceptions -fexceptions -fdiagnostics-show-option = -fcolor-diagnostics -o /tmp/cpp_atomic-3b1ae2.o -x c++ cpp_atomic.cpp clang -cc1 version 5.0.0 based upon LLVM 5.0.0svn default target = powerpc-unknown-freebsd12.0 #include "..." search starts here: #include <...> search starts here: /usr/include/c++/v1 /usr/lib/clang/5.0.0/include /usr/include End of search list. "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 = --enable-new-dtags -m elf32ppc_fbsd -o a.out /usr/lib/crt1.o = /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/cpp_atomic-3b1ae2.o = -lc++ -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed = -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o # ./a.out # So, the example works fine. Nothing about that example program would seem to match the note: -- Looking for __atomic_load_8 in atomic I would guess that the __atomic_load_8 test is somewhat different. . . Looking at an expansion of a wrkdirs' .tbz that poudriere produced, CheckAtomic.cmake has . . . . . . # Check for 64 bit atomic operations. if(MSVC) set(HAVE_CXX_ATOMICS64_WITHOUT_LIB True) else() check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB) endif() # If not, check if the library exists, and atomics work with it. if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB) check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64) if(HAVE_CXX_LIBATOMICS64) list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB) if (NOT HAVE_CXX_ATOMICS64_WITH_LIB) message(FATAL_ERROR "Host compiler must support std::atomic!") endif() else() message(FATAL_ERROR "Host compiler appears to require libatomic, but = cannot find it.") endif() endif() . . . =46rom this I get: A) check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB) set: NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB B) check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64) set: NOT HAVE_CXX_LIBATOMICS64 For (A), looking at the test code (found by name-text matching): function(check_working_cxx_atomics64 varname) set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS "-std=3Dc++11 ${CMAKE_REQUIRED_FLAGS}") CHECK_CXX_SOURCE_COMPILES(" #include <atomic> #include <cstdint> std::atomic<uint64_t> x (0); int main() { uint64_t i =3D x.load(std::memory_order_relaxed); return 0; } " ${varname}) set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) endfunction(check_working_cxx_atomics64) I see: #include <atomic> #include <cstdint> std::atomic<uint64_t> x (0); int main() { uint64_t i =3D x.load(std::memory_order_relaxed); return 0; } Trying that example I see: /tmp/cpp_atomic_64_test-1fa999.o: In function `main': cpp_atomic_64_test.cpp:(.text+0xa8): undefined reference to = `__atomic_load_8' clang++: error: linker command failed with exit code 1 (use -v to see = invocation) Details: # more cpp_atomic_64_test.cpp=20 #include <atomic> #include <cstdint> std::atomic<uint64_t> x (0); int main() { uint64_t i =3D x.load(std::memory_order_relaxed); return 0; } # clang++ -v cpp_atomic_64_test.cpp=20 FreeBSD clang version 5.0.0 (tags/RELEASE_500/final 312559) (based on = LLVM 5.0.0svn) Target: powerpc-unknown-freebsd12.0 Thread model: posix InstalledDir: /usr/bin "/usr/bin/clang++" -cc1 -triple powerpc-unknown-freebsd12.0 -emit-obj = -mrelax-all -disable-free -main-file-name cpp_atomic_64_test.cpp = -mrelocation-model static -mthread-model posix -mdisable-fp-elim = -masm-verbose -mconstructor-aliases -target-cpu ppc -mfloat-abi hard -v = -dwarf-column-info -debugger-tuning=3Dgdb -resource-dir = /usr/lib/clang/5.0.0 -internal-isystem /usr/include/c++/v1 = -fdeprecated-macro -fdebug-compilation-dir /root/c_tests -ferror-limit = 19 -fmessage-length 200 -fno-signed-char -fobjc-runtime=3Dgnustep = -fcxx-exceptions -fexceptions -fdiagnostics-show-option = -fcolor-diagnostics -o /tmp/cpp_atomic_64_test-1fa999.o -x c++ = cpp_atomic_64_test.cpp clang -cc1 version 5.0.0 based upon LLVM 5.0.0svn default target = powerpc-unknown-freebsd12.0 #include "..." search starts here: #include <...> search starts here: /usr/include/c++/v1 /usr/lib/clang/5.0.0/include /usr/include End of search list. "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 = --enable-new-dtags -m elf32ppc_fbsd -o a.out /usr/lib/crt1.o = /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib = /tmp/cpp_atomic_64_test-1fa999.o -lc++ -lm -lgcc --as-needed -lgcc_s = --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed = /usr/lib/crtend.o /usr/lib/crtn.o /tmp/cpp_atomic_64_test-1fa999.o: In function `main': cpp_atomic_64_test.cpp:(.text+0xa8): undefined reference to = `__atomic_load_8' clang++: error: linker command failed with exit code 1 (use -v to see = invocation) > On Tue, Dec 05, 2017 at 10:42:49AM -0800, Mark Millard wrote: >> [I experiment with system-clang based >> buildworld and/or buildkernel based >> TARGET_ARCH=3Dpowerpc64 and >> TARGET_ARCH=3Dpowerpc environments.] >>=20 >> For TARGET_ARCH=3Dpowerpc devel/llvm40 and >> devel/llvm50 get failure reports like: >>=20 >> -- Looking for __atomic_load_8 in atomic - not found >> CMake Error at cmake/modules/CheckAtomic.cmake:74 (message): >> Host compiler appears to require libatomic, but cannot find it. >> Call Stack (most recent call first): >> cmake/config-ix.cmake:307 (include) >> CMakeLists.txt:582 (include) >>=20 >>=20 >> I had tried to avoid any need for 8-Byte atomics >> (among other things) by avoiding LIT, LLD, and LLDB: >>=20 >> # more /usr/local/etc/poudriere.d/options/devel_llvm50/options >> # This file is auto-generated by 'make config'. >> # Options for llvm50-5.0.0_1 >> _OPTIONS_READ=3Dllvm50-5.0.0_1 >> _FILE_COMPLETE_OPTIONS_LIST=3DCLANG DOCS EXTRAS LIT LLD LLDB >> OPTIONS_FILE_SET+=3DCLANG >> OPTIONS_FILE_SET+=3DDOCS >> OPTIONS_FILE_SET+=3DEXTRAS >> OPTIONS_FILE_UNSET+=3DLIT >> OPTIONS_FILE_UNSET+=3DLLD >> OPTIONS_FILE_UNSET+=3DLLDB >>=20 >> # more /usr/local/etc/poudriere.d/options/devel_llvm40/options >> # This file is auto-generated by 'make config'. >> # Options for llvm40-4.0.1_1 >> _OPTIONS_READ=3Dllvm40-4.0.1_1 >> _FILE_COMPLETE_OPTIONS_LIST=3DCLANG DOCS EXTRAS LIT LLD LLDB >> OPTIONS_FILE_SET+=3DCLANG >> OPTIONS_FILE_SET+=3DDOCS >> OPTIONS_FILE_SET+=3DEXTRAS >> OPTIONS_FILE_UNSET+=3DLIT >> OPTIONS_FILE_UNSET+=3DLLD >> OPTIONS_FILE_UNSET+=3DLLDB >>=20 >> For clang-based buildworld avoiding such things >> prevents running into the 8-Byte atomics based >> build failures: >>=20 >> WITH_LIBCPLUSPLUS=3D >> WITH_BINUTILS_BOOTSTRAP=3D >> WITH_ELFTOOLCHAIN_BOOTSTRAP=3D >> #WITH_CLANG_BOOTSTRAP=3D >> WITH_CLANG=3D >> WITH_CLANG_IS_CC=3D >> WITH_CLANG_FULL=3D >> WITH_CLANG_EXTRAS=3D >> WITH_LLD=3D >> # lldb requires missing atomic 8-byte operations for powerpc (non-64) >> WITHOUT_LLDB=3D >> # >> WITH_BOOT=3D >>=20 >> (Note: buildkernel currently fails.) >>=20 >> # clang++ --version >> FreeBSD clang version 5.0.0 (tags/RELEASE_500/final 312559) (based on = LLVM 5.0.0svn) >> Target: powerpc-unknown-freebsd12.0 >> Thread model: posix >> InstalledDir: /usr/bin >>=20 >> # uname -apKU >> FreeBSD FBSDG4S 12.0-CURRENT FreeBSD 12.0-CURRENT r326192M powerpc = powerpc 1200054 1200054 >>=20 >> # svnlite info /usr/ports/ | grep "Re[plv]" >> Relative URL: ^/head >> Repository Root: https://svn.freebsd.org/ports >> Repository UUID: 35697150-7ecd-e111-bb59-0022644237b5 >> Revision: 455204 >> Last Changed Rev: 455204 >=20 Side note: I see that you have been working on the powerpc/powerpc64 problem for generating libraries to handle thrown C++ exceptions, even making the problem description better/more-detailed/specific for the llvm bugzilla entry, now: __builtin_eh_return is not implemented for PPC nor PPC64 and referencing a start at changes for this: I have a WIP patch at http://vlakno.cz/~rdivacky/ppc64.eh_return.patch if anyone wants to take a look and finish it. Cool --and thanks! =3D=3D=3D Mark Millard markmi at dsl-only.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?92AC463A-4A91-4DC2-8536-1026DD5212B6>