Ld lld error undefined symbol

How to reproduce To set up the basic build environment have look at the build guide here: https://developer.sony.com/develop/open-devices/guides/aosp-build-instructions/build-aosp-android-android-1...

How to reproduce

  1. To set up the basic build environment have look at the build guide here:
    https://developer.sony.com/develop/open-devices/guides/aosp-build-instructions/build-aosp-android-android-10-0-0 you have to follow the instructions to:
    https://developer.sony.com/develop/open-devices/guides/aosp-build-instructions/build-aosp-android-android-10-0-0#tutorial-step-3
  2. tutorial-step-4 and following will be handled by my script. Execute the shell script contained in build-4.14-ccache.tar.gz
    build script updated: Nov 12 07:00

Actual behavior

[ 66% 72657/109596] //bionic/libc:libc link libc.so [arm]
FAILED: out/soong/.intermediates/bionic/libc/libc/android_arm_armv8-a_cortex-a73_core_shared_com.android.runtime.debug/unstripped/libc.so
prebuilts/clang/host/linux-x86/clang-r353983c/bin/clang++  @out/soong/.intermediates/bionic/libc/libc/android_arm_armv8-a_cortex-a73_core_shared_com.android.runtime.debug/unstripped/libc.so.rsp -Wl,--whole-archive  out/soong/.intermediates/external/jemalloc_new/libjemalloc5/android_arm_armv8-a_cortex-a73_core_static_com.android.runtime.debug/libjemalloc5.a out/soong/.intermediates/bionic/libc/libc_init_dynamic/android_arm_armv8-a_cortex-a73_core_static_com.android.runtime.debug/libc_init_dynamic.a out/soong/.intermediates/bionic/libc/libc_common_shared/android_arm_armv8-a_cortex-a73_core_static_com.android.runtime.debug/libc_common_shared.a -Wl,--no-whole-archive  out/soong/.intermediates/bionic/libdl/libdl_android/android_arm_armv8-a_cortex-a73_core_static_com.android.runtime.debug/libdl_android.a prebuilts/clang/host/linux-x86/clang-r353983c/lib64/clang/9.0.3/lib/linux/libclang_rt.builtins-arm-android.a prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/arm-linux-androideabi/lib/libatomic.a out/soong/.intermediates/build/soong/libgcc_stripped/android_arm_armv8-a_cortex-a73_core_static_com.android.runtime.debug/libgcc_stripped.a out/soong/.intermediates/bionic/linker/ld-android/android_arm_armv8-a_cortex-a73_core_shared_com.android.runtime.debug/ld-android.so out/soong/.intermediates/bionic/libdl/libdl/android_arm_armv8-a_cortex-a73_core_shared_com.android.runtime.debug/libdl.so  -o out/soong/.intermediates/bionic/libc/libc/android_arm_armv8-a_cortex-a73_core_shared_com.android.runtime.debug/unstripped/libc.so -nostdlib -Wl,--gc-sections -shared -Wl,-soname,libc.so -target armv7a-linux-androideabi -Bprebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/arm-linux-androideabi/bin -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--build-id=md5 -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined-version -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_stripped.a -fuse-ld=lld -Wl,--pack-dyn-relocs=none -Wl,--no-undefined -Wl,--icf=safe -Wl,--hash-style=gnu -Wl,-m,armelf -Wl,-z,muldefs -Wl,--hash-style=both  -Wl,--version-script,out/soong/.intermediates/bionic/libc/libc.arm.map/gen/libc.arm.map -Wl,--symbol-ordering-file,bionic/libc/symbol_ordering
ld.lld: error: undefined symbol: strcpy_a9
>>> referenced by dynamic_function_dispatch.cpp:0 (bionic/libc/arch-arm/dynamic_function_dispatch.cpp:0)
>>>               dynamic_function_dispatch.o:(strcpy) in archive out/soong/.intermediates/bionic/libc/libc_common_shared/android_arm_armv8-a_cortex-a73_core_static_com.android.runtime.debug/libc_common_shared.a

ld.lld: error: undefined symbol: stpcpy_a9
>>> referenced by dynamic_function_dispatch.cpp:0 (bionic/libc/arch-arm/dynamic_function_dispatch.cpp:0)
>>>               dynamic_function_dispatch.o:(stpcpy) in archive out/soong/.intermediates/bionic/libc/libc_common_shared/android_arm_armv8-a_cortex-a73_core_static_com.android.runtime.debug/libc_common_shared.a
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
06:59:15 ninja failed with: exit status 1

It was working fine when I was using ccache version 3.7.4-1 on Debian testing

Expected behavior

The build should run without any error. When setting USE_CCACHE=0 the build succeeds.

Environment

ccache version 3.7.5-1 on Debian testing.

The debian maintainer of the ccache package requested to open as well a bug here. See as well the debian bug:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=944399
The bug was originally reported by me here:
sonyxperiadev/bug_tracker#492

The sources and build uses quite some space:
stefan@mars:~/android/source$ du -hs .
258G .

ccache stats after initial build (ccache was cleared before):
stefan@mars:~/android/source$ ccache -s
cache directory /home/stefan/.ccache
primary config /home/stefan/.ccache/ccache.conf
secondary config (readonly) /etc/ccache.conf
stats updated Tue Nov 12 06:29:41 2019
stats zeroed Sat Nov 9 00:52:50 2019
cache hit (direct) 194
cache hit (preprocessed) 5523
cache miss 28697
cache hit rate 16.61 %
called for link 1
called for preprocessing 26
unsupported code directive 1
cleanups performed 0
files in cache 90898
cache size 13.6 GB
max cache size 53.7 GB

Building it on a 4 core machine (Intel(R) Core(TM) i5-6300HQ CPU @
2.30GHz) takes 02:24:20.

The full stdout/stderr output of the build script including the error message: build.log.tar.gz

Hope you can reproduce the issue. If you need any assistance I’d be happy to help.

Best regards
Stefan

Background

llvm, clang, libcxx/libcxxabi are built from source by me. they are located at usr/local.

Minimum source file

//findpath.cpp

#include <iostream>
int main(){
    std::cout << "Hi";
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_C_COMPILER "clang")

project(FindPath)
add_compile_options("-stdlib=libc++" "-lc++abi" "-v")

add_executable(path findpath.cpp)

With cmake(output linker error)

~/.../findpath/build >>> cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..                                                                                                ±[●][master]
-- The C compiler identification is Clang 8.0.0
-- The CXX compiler identification is Clang 8.0.0
-- Check for working C compiler: /usr/local/bin/clang
-- Check for working C compiler: /usr/local/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/firstlove/projects/smalltools/findpath/build
~/.../findpath/build >>> make                                                                                                                                      ±[●][master]
Scanning dependencies of target path
[ 50%] Building CXX object CMakeFiles/path.dir/findpath.cpp.o
clang version 8.0.0 (http://llvm.org/git/clang 55ead9f6f66545bcfda4a0f7e6dd3748a296f826) (https://github.com/llvm-mirror/llvm.git 8d97f0d4be38ebd4b38fe2cff51e0713b3dfba66)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
clang-8: warning: -lc++abi: 'linker' input unused [-Wunused-command-line-argument]
 "/usr/local/bin/clang-8" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name findpath.cpp -mr
elocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column
-info -debugger-tuning=gdb -v -coverage-notes-file /home/firstlove/projects/smalltools/findpath/build/CMakeFiles/path.dir/findpath.cpp.gcno -resource-dir /usr/local/lib/clang/8
.0.0 -internal-isystem /usr/local/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/local/lib/clang/8.0.0/include -internal-externc-isystem /inc
lude -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/firstlove/projects/smalltools/findpath/build -ferror-limit 19 -fmessage-length 176 
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o CMakeFiles/path.dir/findpath.cpp.o -x c++ /home/firstlove/projects/smalltools/
findpath/findpath.cpp -faddrsig
clang -cc1 version 8.0.0 based upon LLVM 8.0.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/bin/../include/c++/v1
 /usr/local/include
 /usr/local/lib/clang/8.0.0/include
 /usr/include
End of search list.
[100%] Linking CXX executable path
CMakeFiles/path.dir/findpath.cpp.o: In function `main':
findpath.cpp:(.text+0xa): undefined reference to `std::__1::cout'
CMakeFiles/path.dir/findpath.cpp.o: In function `std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<cha
r> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long)':
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x2f): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, st
d::__1::char_traits<char> >&)'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x1be): undefined reference to `std::__1::ios_base::getloc() const'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x1d4): undefined reference to `std::__1::ctype<char>::id'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x1d9): undefined reference to `std::__1::locale::use_facet(std::__1::locale::id&) const'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x235): undefined reference to `std::__1::locale::~locale()'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x257): undefined reference to `std::__1::locale::~locale()'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x327): undefined reference to `std::__1::ios_base::clear(unsigned int)'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x384): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x3ad): undefined reference to `std::__1::ios_base::__set_badbit_and_consider_rethrow()'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x3d8): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()'
CMakeFiles/path.dir/findpath.cpp.o: In function `std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> 
>(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char)':
findpath.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_tr
aitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x219): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::a
llocator<char> >::__init(unsigned long, char)'
findpath.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_tr
aitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x388): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::a
llocator<char> >::~basic_string()'
findpath.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_tr
aitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x3a3): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::a
llocator<char> >::~basic_string()'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/path.dir/build.make:84: path] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/path.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Without cmake(no link error): clang++ -stdlib=libc++ -lc++abi -std=c++17 -v findpath.cpp

~/.../smalltools/findpath >>> clang++ -stdlib=libc++ -lc++abi -std=c++17 -v findpath.cpp                                                                           ±[●][master]
clang version 8.0.0 (http://llvm.org/git/clang 55ead9f6f66545bcfda4a0f7e6dd3748a296f826) (https://github.com/llvm-mirror/llvm.git 8d97f0d4be38ebd4b38fe2cff51e0713b3dfba66)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/local/bin/clang-8" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name findpath.cpp -mr
elocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column
-info -debugger-tuning=gdb -v -resource-dir /usr/local/lib/clang/8.0.0 -internal-isystem /usr/local/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem
 /usr/local/lib/clang/8.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/firstl
ove/projects/smalltools/findpath -ferror-limit 19 -fmessage-length 176 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/fi
ndpath-7dd1ae.o -x c++ findpath.cpp -faddrsig
clang -cc1 version 8.0.0 based upon LLVM 8.0.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/bin/../include/c++/v1
 /usr/local/include
 /usr/local/lib/clang/8.0.0/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../lib64/crt1.o /usr/lib64/gc
c/x86_64-pc-linux-gnu/8.1.1/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/crtbegin.o -L/usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1 -L/usr/lib64/gcc/x86_64-pc-l
inux-gnu/8.1.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../.. -L/usr/local/bin/../lib -L/lib -L/usr/lib -lc++abi /tmp
/findpath-7dd1ae.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/crtend.o /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../lib64/crtn.o

But from /usr/bin/ld, it seems use gcc to link?


I have google much, but nothing useful found. If any more information needed, please tell me, thanks in advance.

Update

  • I also tried set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi"), but still popup the same linker error.

  • To verify whether the problem arises from the source built llvm, clang, libcxx, libcxxabi, I reinstaled os and installed from pacman, unfortunatelly, nothing changed.

  • use VERBOSE=1 make: https://paste.ubuntu.com/p/t5yycfdmsc/

Except for telling me the linker is gnu’s ld, other error messages are the same.

Then I give llvm’s lld a try,

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -stdlib=libc++ -lc++abi")

/usr/bin/cmake -H/home/firstlove/projects/smallProjects/smalltools/findpath -B/home/firstlove/projects/smallProjects/smalltools/findpath/build --check-build-system CMakeFiles/M
akefile.cmake 0                                                                                                                                                                
/usr/bin/cmake -E cmake_progress_start /home/firstlove/projects/smallProjects/smalltools/findpath/build/CMakeFiles /home/firstlove/projects/smallProjects/smalltools/findpath/bu
ild/CMakeFiles/progress.marks                                                                                                                                                  
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
make -f CMakeFiles/path.dir/build.make CMakeFiles/path.dir/depend
make[2]: Entering directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
cd /home/firstlove/projects/smallProjects/smalltools/findpath/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/firstlove/projects/smallProjects/smalltools/findpa
th /home/firstlove/projects/smallProjects/smalltools/findpath /home/firstlove/projects/smallProjects/smalltools/findpath/build /home/firstlove/projects/smallProjects/smalltools
/findpath/build /home/firstlove/projects/smallProjects/smalltools/findpath/build/CMakeFiles/path.dir/DependInfo.cmake --color=                                                 
make[2]: Leaving directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
make -f CMakeFiles/path.dir/build.make CMakeFiles/path.dir/build
make[2]: Entering directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
[ 50%] Linking CXX executable path
/usr/bin/cmake -E cmake_link_script CMakeFiles/path.dir/link.txt --verbose=1
clang++     -fuse-ld=lld -stdlib=libc++ -lc++abi CMakeFiles/path.dir/findpath.cpp.o  -o path 
/usr/bin/ld.lld: error: undefined symbol: std::cout
>>> referenced by findpath.cpp
>>>               CMakeFiles/path.dir/findpath.cpp.o:(main)

/usr/bin/ld.lld: error: undefined symbol: std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<
char> >&, char const*)                                                                                                                                                         
>>> referenced by findpath.cpp
>>>               CMakeFiles/path.dir/findpath.cpp.o:(main)

/usr/bin/ld.lld: error: undefined symbol: std::ios_base::Init::Init()
>>> referenced by findpath.cpp
>>>               CMakeFiles/path.dir/findpath.cpp.o:(__cxx_global_var_init)

/usr/bin/ld.lld: error: undefined symbol: std::ios_base::Init::~Init()
>>> referenced by findpath.cpp
>>>               CMakeFiles/path.dir/findpath.cpp.o:(__cxx_global_var_init)
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/path.dir/build.make:84: path] Error 1
make[2]: Leaving directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/path.dir/all] Error 2
make[1]: Leaving directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
make: *** [Makefile:84: all] Error 2

Oops, similar linker error…

Again, without cmake, it works fine:

~/.../smalltools/findpath >>> clang++ -stdlib=libc++ -lc++abi -std=c++17 -v -fuse-ld=lld findpath.cpp                                                            ±[A1●][master]
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/8.2.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/clang-6.0" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name findpath.cpp -mrelocation
-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 
-dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/clang/6.0.1 -internal-isystem /usr/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isyste
m /usr/lib/clang/6.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/firstlove/p
rojects/smallProjects/smalltools/findpath -ferror-limit 19 -fmessage-length 176 -stack-protector 2 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -f
color-diagnostics -o /tmp/findpath-671136.o -x c++ findpath.cpp                                                                                                                
clang -cc1 version 6.0.1 based upon LLVM 6.0.1 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../include/c++/v1
 /usr/local/include
 /usr/lib/clang/6.0.1/include
 /usr/include
End of search list.
 "/usr/bin/ld.lld" -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/Scrt
1.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/crtbeginS.o -L/usr/bin/../lib64/gcc/x86_64-pc-linux
-gnu/8.2.0 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-g
nu/8.2.0/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib -lc++abi /tmp/findpath-671136.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/
crtendS.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/crtn.o                                                                                             
~/.../smalltools/findpath >>>                                                                                                                                   ±[A1●●][master]
~/.../smalltools/findpath >>> ./a.out                                                                                                                           ±[A1●●][master]
Hi%                                                                                                                                                                             

Содержание

  1. Linking fails with «undefined symbol: main» #322
  2. Comments
  3. Footer
  4. Undefined symbol #7
  5. Comments
  6. Линковщик clang’а не видит функцию в заголовочном файле
  7. Building aosp-10 bionic leads to ld.lld: error: undefined symbol: stpcpy_a9 #489
  8. Comments
  9. How to reproduce
  10. Actual behavior
  11. Expected behavior
  12. Environment
  13. ld: error: undefined symbol when compile rodio crate dependency #167
  14. Comments
  15. Error
  16. Steps to reproduce

Linking fails with «undefined symbol: main» #322

I tried to build the latest version (85e3cf0) by following the instructions. I think the linker cannot find the main function.
Here’s an excerpt of the messages show by ninja:

Compiler: gcc 11 (wrapped by ccache)
Linker: lld 12 (using a symbolic link from

/bin/ld to /usr/bin/ld.lld)

The text was updated successfully, but these errors were encountered:

Thank you for the report. I just tried to compile using clang (on macOS) and things worked correctly.

Could you try running the following commands to see if it fixes the problem for you? This is assuming you’re in the base taisei/ directory.

Let me know if that ends up working for you. I’m also currently working on better documentation for building, which you can check out in #319.

I think this might be the problem here, combined with Taisei’s LTO-by-default setting. lld probably does not understand gcc’s LTO object format, so it fails to link anything into the binary. I would not recommend using lld and gcc together, and especially wouldn’t recommend overriding your system’s default linker like that (if you must, you can tell the compiler which linker to use via -fuse-ld=lld ). To test this hypothesis, try disabling LTO via meson configure -Db_lto=false and recompiling. That should give you a working build with gcc+lld, albeit less optimized. If that works, I would recommend enabling LTO back and either using the gold linker with gcc ( meson configure -Dcpp_link_args=»-fuse-ld=gold» ), or using clang if you want to use lld.

Thanks for the help.
Changing the linker indeed fixed the problem; there is an related issue at llvm.org: Bug 42446.

© 2023 GitHub, Inc.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

Undefined symbol #7

I have followed the instructions on the README until the command ninja -C out/Default third_party/cld_3/src/src:language_identifier_main . I have uncommented language_identifier_main and set the PATH variable but when I run that command I get the following error. I have tried changing the created files, updated gcc but I am not sure why it is failing on loading std libraries.

basic_string() >>> referenced by language_identifier_main.cc:54 (../../third_party/cld_3/src/src/language_identifier_main.cc:54) >>> obj/third_party/cld_3/src/src/language_identifier_main/language_identifier_main.o:(main) /home/myuser/chromium/src/out/Default/../../third_party/llvm-build/Release+Asserts/bin/ld.lld: error: undefined symbol: std::__1::ios_base::getloc() const >>> referenced by ios:756 (../../buildtools/third_party/libc++/trunk/include/ios:756) >>> obj/third_party/cld_3/src/src/language_identifier_main/language_identifier_main.o:(std::__1::basic_ostream >& std::__1::endl >(std::__1::basic_ostream >&)) /home/myuser/chromium/src/out/Default/../../third_party/llvm-build/Release+Asserts/bin/ld.lld: error: undefined symbol: std::__1::ctype ::id >>> referenced by ios:756 (../../buildtools/third_party/libc++/trunk/include/ios:756) >>> obj/third_party/cld_3/src/src/language_identifier_main/language_identifier_main.o:(std::__1::basic_ostream >& std::__1::endl >(std::__1::basic_ostream >&)) /home/myuser/chromium/src/out/Default/../../third_party/llvm-build/Release+Asserts/bin/ld.lld: error: undefined symbol: std::__1::locale::use_facet(std::__1::locale::id&) const >>> referenced by __locale:212 (../../buildtools/third_party/libc++/trunk/include/__locale:212) >>> obj/third_party/cld_3/src/src/language_identifier_main/language_identifier_main.o:(std::__1::basic_ostream >& std::__1::endl >(std::__1::basic_ostream >&)) /home/myuser/chromium/src/out/Default/../../third_party/llvm-build/Release+Asserts/bin/ld.lld: error: undefined symbol: std::__1::locale::

locale() >>> referenced by ios:756 (../../buildtools/third_party/libc++/trunk/include/ios:756) >>> obj/third_party/cld_3/src/src/language_identifier_main/language_identifier_main.o:(std::__1::basic_ostream >& std::__1::endl >(std::__1::basic_ostream >&)) /home/myuser/chromium/src/out/Default/../../third_party/llvm-build/Release+Asserts/bin/ld.lld: error: undefined symbol: std::__1::basic_ostream >::put(char) >>> referenced by ostream:1001 (../../buildtools/third_party/libc++/trunk/include/ostream:1001) >>> obj/third_party/cld_3/src/src/language_identifier_main/language_identifier_main.o:(std::__1::basic_ostream >& std::__1::endl >(std::__1::basic_ostream >&)) /home/myuser/chromium/src/out/Default/../../third_party/llvm-build/Release+Asserts/bin/ld.lld: error: undefined symbol: std::__1::basic_ostream >::flush() >>> referenced by ostream:1002 (../../buildtools/third_party/libc++/trunk/include/ostream:1002) >>> obj/third_party/cld_3/src/src/language_identifier_main/language_identifier_main.o:(std::__1::basic_ostream >& std::__1::endl >(std::__1::basic_ostream >&)) /home/myuser/chromium/src/out/Default/../../third_party/llvm-build/Release+Asserts/bin/ld.lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors) clang: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.»>

The text was updated successfully, but these errors were encountered:

Источник

Линковщик clang’а не видит функцию в заголовочном файле

Доброго времени суток.

Не получается собрать clang’ом, на win7+gcc то же самое собирается без проблем. Другие функции из math.h кроме powf(), powl() вызываются исправно. В чём может быть причина? Заранее спасибо.

Другие функции из math.h кроме powf(), powl() вызываются исправно

Потому что компилятор заменяет функции типа sin() на __builtin_sin() , которые на самом деле не функции. Для некоторых функций есть такие встроенные конструкции, и для них связывание с libm не обязательно.

Благодарю тебя, добрый человек. На полном серьёзе и без сарказма.

А -lm компилятору передавать Пушкин будет?

Да, знаю, идиотизм, но так уж повелось.

А -lm компилятору передавать Пушкин будет?

Чем стебаться над бедным быдлокодырем, сказал бы лучше почему ключа -lm нет ни в мануале clang, ни в хелпе. И откуда такая фича вообще появилась, раз так хорошо знаешь предмет.

И откуда такая фича вообще появилась,

Это еще из первого стандарта языка такое, что математическую библиотеку отдельно держат. Для экономии. Соответственно про -lm можно прочитать в K&R.

У меня под лапой бумажная версия K&R и справочник шилдта, и ни в одной из 2х в главах о math.h ничего про -lm. Разупорись.

сказал бы лучше почему ключа -lm нет ни в мануале clang, ни в хелпе.

Потому что clang — компилятор, а за библиотеки отвечает компоновщик.

Ок, покажи строку из мануала по ld, где упоминается ключ -lm.

А мануал на функцию тебе, дегенерату, чем не подходит?

Нет. Именно компилятор отвечает за набор библиотек по умолчанию и обычно компилятор вызывает линкер.

У автора темы OpenBSD, может там по другому. Например в Haiku вместо -lc -lm -lpthread одна библиотека -lroot .

Сразу видно настоящего Специалиста!

Именно компилятор отвечает за набор библиотек по умолчанию

Компилятор, который занимается компиляцией, не может знать набор библиотек «по умолчанию». Это может знать только компоновщик (и/или фронтенд ко всей этой машинерии), который может быть частью «компилятора» — как пакета программ для разработки.

И об этом он тоже должен узнать из документации на свою среду разработки.

Компилятор, который занимается компиляцией, не может знать набор библиотек «по умолчанию».

И да, у шланга вообще не было компоновщика на некоторые платформы очень длительное время. Т.е. компилировать им можно было, а компоновать уже надо было сторонним компоновщиком.

Это может знать только компоновщик (и/или фронтенд ко всей этой машинерии), который может быть частью «компилятора» — как пакета программ для разработки.

Компоновщик как раз ничего не знает. Он получает список библиотек по умолчанию от компилятора. Попробуйте слинковаять через gcc/clang test-app.o -o test-app и ld/ld.lld/mold test-app.o -o test-app и заметьте разницу.

Компоновщик как раз ничего не знает.

Компоновщик будет вести себя так, как его реализуют разработчики компоновщика. Без чтения документации делать догадки о его поведении нельзя. Кроме того, дефолтные библиотеки могут быть забиты во фронтенде, к примеру, и отключаться каким-нибудь /nostdlib .

Источник

Building aosp-10 bionic leads to ld.lld: error: undefined symbol: stpcpy_a9 #489

How to reproduce

  1. To set up the basic build environment have look at the build guide here:
    https://developer.sony.com/develop/open-devices/guides/aosp-build-instructions/build-aosp-android-android-10-0-0 you have to follow the instructions to:
    https://developer.sony.com/develop/open-devices/guides/aosp-build-instructions/build-aosp-android-android-10-0-0#tutorial-step-3
  2. tutorial-step-4 and following will be handled by my script. Execute the shell script contained in build-4.14-ccache.tar.gz
    build script updated: Nov 12 07:00

Actual behavior

It was working fine when I was using ccache version 3.7.4-1 on Debian testing

Expected behavior

The build should run without any error. When setting USE_CCACHE=0 the build succeeds.

Environment

ccache version 3.7.5-1 on Debian testing.

The debian maintainer of the ccache package requested to open as well a bug here. See as well the debian bug:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=944399
The bug was originally reported by me here:
sonyxperiadev/bug_tracker#492

The sources and build uses quite some space:
stefan@mars:

/android/source$ du -hs .
258G .

ccache stats after initial build (ccache was cleared before):
stefan@mars:

/android/source$ ccache -s
cache directory /home/stefan/.ccache
primary config /home/stefan/.ccache/ccache.conf
secondary config (readonly) /etc/ccache.conf
stats updated Tue Nov 12 06:29:41 2019
stats zeroed Sat Nov 9 00:52:50 2019
cache hit (direct) 194
cache hit (preprocessed) 5523
cache miss 28697
cache hit rate 16.61 %
called for link 1
called for preprocessing 26
unsupported code directive 1
cleanups performed 0
files in cache 90898
cache size 13.6 GB
max cache size 53.7 GB

Building it on a 4 core machine (Intel(R) Core(TM) i5-6300HQ CPU @
2.30GHz) takes 02:24:20.

The full stdout/stderr output of the build script including the error message: build.log.tar.gz

Hope you can reproduce the issue. If you need any assistance I’d be happy to help.

Best regards
Stefan

The text was updated successfully, but these errors were encountered:

Источник

ld: error: undefined symbol when compile rodio crate dependency #167

Error

thread()) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: undefined symbol: __gxx_personality_v0 >>> referenced by chrono.cpp >>> chrono.o:(DW.ref.__gxx_personality_v0) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: undefined symbol: std::get_new_handler() >>> referenced by new.cpp:71 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:71) >>> new.o:(operator new(unsigned long)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by new.cpp:190 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:190) >>> new.o:(operator new(unsigned long, std::align_val_t)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: undefined symbol: __cxa_allocate_exception >>> referenced by new.cpp:76 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:76) >>> new.o:(operator new(unsigned long)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by new.cpp:195 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:195) >>> new.o:(operator new(unsigned long, std::align_val_t)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by stdexcept:269 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:269) >>> string.o:(std::__ndk1::__throw_out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced 1 more times ld: error: undefined symbol: std::bad_alloc::bad_alloc() >>> referenced by new.cpp:76 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:76) >>> new.o:(operator new(unsigned long)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by new.cpp:195 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:195) >>> new.o:(operator new(unsigned long, std::align_val_t)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: undefined symbol: typeinfo for std::bad_alloc >>> referenced by new.cpp:76 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:76) >>> new.o:(operator new(unsigned long)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by new.cpp:76 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:76) >>> new.o:(operator new(unsigned long)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by new.cpp:195 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:195) >>> new.o:(operator new(unsigned long, std::align_val_t)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced 1 more times ld: error: undefined symbol: std::bad_alloc::

bad_alloc() >>> referenced by new.cpp:76 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:76) >>> new.o:(operator new(unsigned long)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by new.cpp:76 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:76) >>> new.o:(operator new(unsigned long)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by new.cpp:195 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:195) >>> new.o:(operator new(unsigned long, std::align_val_t)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced 1 more times ld: error: undefined symbol: __cxa_throw >>> referenced by new.cpp:76 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:76) >>> new.o:(operator new(unsigned long)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by new.cpp:195 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/new.cpp:195) >>> new.o:(operator new(unsigned long, std::align_val_t)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by stdexcept:269 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:269) >>> string.o:(std::__ndk1::__throw_out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced 1 more times ld: error: undefined symbol: vtable for std::logic_error >>> referenced by stdexcept_default.ipp:24 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/support/runtime/stdexcept_default.ipp:24) >>> stdexcept.o:(std::logic_error::logic_error(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by stdexcept_default.ipp:24 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/support/runtime/stdexcept_default.ipp:24) >>> stdexcept.o:(std::logic_error::logic_error(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction) ld: error: undefined symbol: std::exception::

exception() >>> referenced by stdexcept_default.ipp:24 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/support/runtime/stdexcept_default.ipp:24) >>> stdexcept.o:(std::logic_error::logic_error(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by stdexcept_default.ipp:33 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/support/runtime/stdexcept_default.ipp:33) >>> stdexcept.o:(std::runtime_error::runtime_error(std::__ndk1::basic_string , std::__ndk1::allocator > const&)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: undefined symbol: vtable for std::runtime_error >>> referenced by stdexcept_default.ipp:33 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/support/runtime/stdexcept_default.ipp:33) >>> stdexcept.o:(std::runtime_error::runtime_error(std::__ndk1::basic_string , std::__ndk1::allocator > const&)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by stdexcept_default.ipp:33 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/support/runtime/stdexcept_default.ipp:33) >>> stdexcept.o:(std::runtime_error::runtime_error(std::__ndk1::basic_string , std::__ndk1::allocator > const&)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction) ld: error: undefined symbol: typeinfo for std::out_of_range >>> referenced by stdexcept:269 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:269) >>> string.o:(std::__ndk1::__throw_out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by stdexcept:269 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:269) >>> string.o:(std::__ndk1::__throw_out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: undefined symbol: std::out_of_range::

out_of_range() >>> referenced by stdexcept:269 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:269) >>> string.o:(std::__ndk1::__throw_out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by stdexcept:269 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:269) >>> string.o:(std::__ndk1::__throw_out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: undefined symbol: __cxa_free_exception >>> referenced by stdexcept:269 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:269) >>> string.o:(std::__ndk1::__throw_out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by system_error.cpp:287 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/system_error.cpp:287) >>> system_error.o:(std::__ndk1::__throw_system_error(int, char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: undefined symbol: vtable for std::out_of_range >>> referenced by stdexcept:167 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:167) >>> string.o:(std::out_of_range::out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by stdexcept:167 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/include/stdexcept:167) >>> string.o:(std::out_of_range::out_of_range(char const*)) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction) ld: error: undefined symbol: std::runtime_error::

runtime_error() >>> referenced by system_error.cpp:281 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/system_error.cpp:281) >>> system_error.o:(std::__ndk1::system_error::

system_error()) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a >>> referenced by system_error.cpp:281 (/buildbot/src/android/ndk-release-r22toolchain/llvm-project/libcxx/src/system_error.cpp:281) >>> system_error.o:(std::__ndk1::system_error::

system_error()) in archive C:UsersandraAppDataLocalAndroidSdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64bin/../sysroot/usr/lib/aarch64-linux-androidlibc++_static.a ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors) clang: error: linker command failed with exit code 1 (use -v to see invocation) error: aborting due to previous error error: could not compile `wgpu-playground`»>

Steps to reproduce

I found another repo that are using Rust for Android & rodio library https://github.com/endragor/cpal-android-test , so I think there should be no problem to compile rodio. I guess there is some problem with the toolchain? I don’t know what should I do.

Isn’t it should use clang++ instead of clang? How do I set it up?

The text was updated successfully, but these errors were encountered:

Источник

yaoming_019

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Hello everyone,

When I compile vasp-5.4.4 with aocc4.0 on amd-zen2 platform,I get an error:

ld.lld: error: undefined symbol: MAIN_
>>> referenced by flangmain.c:59 (/home/amd/JENKINS/workspace/AOCC_4_0_0_INTERIM/flang/runtime/flangmain/flangmain.c:59)
>>> flangmain.c.o:(main) in archive /home/xxx/amd/aocc-compiler-4.0.0/bin/../lib/libflangmain.a
>>> did you mean: MAIN__
>>> defined in: /home/xxx/amd/aocc-compiler-4.0.0/bin/../lib/libflangrti.so
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

Is this a bug in the compiler itself?

1 Solution

santosh_zanjurne

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Hello Yaoming,

Can experiment with below changes in your configuration file?

        CPP        = flang -E -P -C -w -Mfree $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS)

        FC         = mpif90 -fopenmp

        FCL        = mpif90 -fopenmp

        FREE       = -ffree-form -ffree-line-length-none

        FFLAGS     = -w -march=znver3 -fno-fortran-main $(CPP_OPTIONS) -Mbackslash -ffunc-args-alias


  • All forum topics


  • Previous Topic

  • Next Topic

12 Replies

santosh_zanjurne

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Hello Yaoming,

Can experiment with below changes in your configuration file?

        CPP        = flang -E -P -C -w -Mfree $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS)

        FC         = mpif90 -fopenmp

        FCL        = mpif90 -fopenmp

        FREE       = -ffree-form -ffree-line-length-none

        FFLAGS     = -w -march=znver3 -fno-fortran-main $(CPP_OPTIONS) -Mbackslash -ffunc-args-alias

yaoming_019

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Thanks for your reply.

This configuration file is indeed valid. The reason for this error is that clang cannot convert the .F file into a .f90 file. What I want to ask you is which compilation option makes its compilation pass.

This is my first time in the community, so I don’t know if the message to ask you for advice has been sent out, but this question is very urgent for me, so I have to ask again.

Summary

OpenFOAM 2112 completes the build with the following error-ld.lld: error: undefined symbol: typeinfo for Foam::regionModels::regionFaModel
referenced by MPPICInterFoam.C
This doesn’t result in desired number of binaries end of build

Steps to reproduce

export OPENFOAMROOT=<Path_to_OpenFOAM_Installtion> ##current working directory/ PWD ##
 
wget  https://dl.openfoam.com/source/v2112/OpenFOAM-v2112.tgz

wget  https://dl.openfoam.com/source/v2112/ThirdParty-v2112.tgz
 
cd $OPENFOAMROOT
 tar -xzf OpenFOAM-v2112.tgz
 tar -xzf ThirdParty-v2112.tgz
 
export WM_CXXFLAGS="$CFLAGS"
export WM_CFLAGS="$CXXFLAGS"
Edit/Modify these files as per AOCC
$OPENFOAMROOT/OpenFOAM-v2112/etc/bashrc

sed -i 's/WM_COMPILER=Gcc/WM_COMPILER=Amd/' $OPENFOAMROOT/OpenFOAM-v2112/etc/bashrc
 
$OPENFOAMROOT/OpenFOAM-v2112/etc/config.sh/mpi

export MPI_ARCH_PATH= Path to OpenMPI installation 
  
source $OPENFOAMROOT/OpenFOAM-v2112/etc/bashrc

echo $WM_PROJECT_DIR
Build OpenFOAM-v2112
cd $OPENFOAMROOT/OpenFOAM-v2112

time ./Allwmake -j  64 all -k 2>&1 |tee  OpenFOAM_AOCC_install.log

source $OPENFOAMROOT/OpenFOAM-v2112/etc/bashrc

What is the current bug behaviour?

ldd error referencing MPPICInterFoam.C during build. This results in incorrect number of binaries.

What is the expected correct behavior?

clean build without ldd error. 312 binaries are expected. But 311 entries are generated.

Relevant logs and/or images

ld.lld: error: undefined symbol: typeinfo for Foam::regionModels::regionFaModel
referenced by MPPICInterFoam.C
v2112/build/linux64AmdDPInt32Opt/applications/solvers/multiphase/MPPICInterFoam/MPPICInterFoam.ovoid Foam::SurfaceFilmModel<Foam::KinematicCloud<Foam:: Cloud<Foam::KinematicParcelFoam:article > > >::inject<Foam::KinematicCloud<Foam::Cloud<Foam::K inematicParcelFoam:article > > >(Foam::KinematicCloud<Foam::Cloud<Foam::Kinematic ParcelFoam:article > >&))
referenced by MPPICInterFoam.C

Environment information

Providing details of your set-up can help us identify any issues, e.g.

OpenFOAM version : v2112

Operating system : centos 8.3

Hardware info : AMD Epyc 7763

Compiler : clang/Aocc 3.2

Possible fixes

We have currently found a workaround by linking -lregionFaModels in the line

«LINK_LIBS = $(c++DBUG) -Wl,—as-needed -lregionFaModels«

path — OpenFOAM-v2112/wmake/rules/General/Amd/link-c++

do we have any official fix for this ?

Background

llvm, clang, libcxx/libcxxabi are built from source by me. they are located at usr/local.

Minimum source file

//findpath.cpp

#include <iostream>
int main(){
    std::cout << "Hi";
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_C_COMPILER "clang")

project(FindPath)
add_compile_options("-stdlib=libc++" "-lc++abi" "-v")

add_executable(path findpath.cpp)

With cmake(output linker error)

~/.../findpath/build >>> cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..                                                                                                ±[●][master]
-- The C compiler identification is Clang 8.0.0
-- The CXX compiler identification is Clang 8.0.0
-- Check for working C compiler: /usr/local/bin/clang
-- Check for working C compiler: /usr/local/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/firstlove/projects/smalltools/findpath/build
~/.../findpath/build >>> make                                                                                                                                      ±[●][master]
Scanning dependencies of target path
[ 50%] Building CXX object CMakeFiles/path.dir/findpath.cpp.o
clang version 8.0.0 (http://llvm.org/git/clang 55ead9f6f66545bcfda4a0f7e6dd3748a296f826) (https://github.com/llvm-mirror/llvm.git 8d97f0d4be38ebd4b38fe2cff51e0713b3dfba66)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
clang-8: warning: -lc++abi: 'linker' input unused [-Wunused-command-line-argument]
 "/usr/local/bin/clang-8" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name findpath.cpp -mr
elocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column
-info -debugger-tuning=gdb -v -coverage-notes-file /home/firstlove/projects/smalltools/findpath/build/CMakeFiles/path.dir/findpath.cpp.gcno -resource-dir /usr/local/lib/clang/8
.0.0 -internal-isystem /usr/local/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/local/lib/clang/8.0.0/include -internal-externc-isystem /inc
lude -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/firstlove/projects/smalltools/findpath/build -ferror-limit 19 -fmessage-length 176 
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o CMakeFiles/path.dir/findpath.cpp.o -x c++ /home/firstlove/projects/smalltools/
findpath/findpath.cpp -faddrsig
clang -cc1 version 8.0.0 based upon LLVM 8.0.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/bin/../include/c++/v1
 /usr/local/include
 /usr/local/lib/clang/8.0.0/include
 /usr/include
End of search list.
[100%] Linking CXX executable path
CMakeFiles/path.dir/findpath.cpp.o: In function `main':
findpath.cpp:(.text+0xa): undefined reference to `std::__1::cout'
CMakeFiles/path.dir/findpath.cpp.o: In function `std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<cha
r> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long)':
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x2f): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, st
d::__1::char_traits<char> >&)'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x1be): undefined reference to `std::__1::ios_base::getloc() const'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x1d4): undefined reference to `std::__1::ctype<char>::id'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x1d9): undefined reference to `std::__1::locale::use_facet(std::__1::locale::id&) const'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x235): undefined reference to `std::__1::locale::~locale()'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x257): undefined reference to `std::__1::locale::~locale()'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x327): undefined reference to `std::__1::ios_base::clear(unsigned int)'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x384): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x3ad): undefined reference to `std::__1::ios_base::__set_badbit_and_consider_rethrow()'
findpath.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEER
NS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x3d8): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()'
CMakeFiles/path.dir/findpath.cpp.o: In function `std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> 
>(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char)':
findpath.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_tr
aitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x219): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::a
llocator<char> >::__init(unsigned long, char)'
findpath.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_tr
aitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x388): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::a
llocator<char> >::~basic_string()'
findpath.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_tr
aitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x3a3): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::a
llocator<char> >::~basic_string()'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/path.dir/build.make:84: path] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/path.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Without cmake(no link error): clang++ -stdlib=libc++ -lc++abi -std=c++17 -v findpath.cpp

~/.../smalltools/findpath >>> clang++ -stdlib=libc++ -lc++abi -std=c++17 -v findpath.cpp                                                                           ±[●][master]
clang version 8.0.0 (http://llvm.org/git/clang 55ead9f6f66545bcfda4a0f7e6dd3748a296f826) (https://github.com/llvm-mirror/llvm.git 8d97f0d4be38ebd4b38fe2cff51e0713b3dfba66)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/local/bin/clang-8" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name findpath.cpp -mr
elocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column
-info -debugger-tuning=gdb -v -resource-dir /usr/local/lib/clang/8.0.0 -internal-isystem /usr/local/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem
 /usr/local/lib/clang/8.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/firstl
ove/projects/smalltools/findpath -ferror-limit 19 -fmessage-length 176 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/fi
ndpath-7dd1ae.o -x c++ findpath.cpp -faddrsig
clang -cc1 version 8.0.0 based upon LLVM 8.0.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/bin/../include/c++/v1
 /usr/local/include
 /usr/local/lib/clang/8.0.0/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../lib64/crt1.o /usr/lib64/gc
c/x86_64-pc-linux-gnu/8.1.1/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/crtbegin.o -L/usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1 -L/usr/lib64/gcc/x86_64-pc-l
inux-gnu/8.1.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../.. -L/usr/local/bin/../lib -L/lib -L/usr/lib -lc++abi /tmp
/findpath-7dd1ae.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/crtend.o /usr/lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../lib64/crtn.o

But from /usr/bin/ld, it seems use gcc to link?


I have google much, but nothing useful found. If any more information needed, please tell me, thanks in advance.

Update

  • I also tried set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi"), but still popup the same linker error.

  • To verify whether the problem arises from the source built llvm, clang, libcxx, libcxxabi, I reinstaled os and installed from pacman, unfortunatelly, nothing changed.

  • use VERBOSE=1 make: https://paste.ubuntu.com/p/t5yycfdmsc/

Except for telling me the linker is gnu’s ld, other error messages are the same.

Then I give llvm’s lld a try,

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -stdlib=libc++ -lc++abi")

/usr/bin/cmake -H/home/firstlove/projects/smallProjects/smalltools/findpath -B/home/firstlove/projects/smallProjects/smalltools/findpath/build --check-build-system CMakeFiles/M
akefile.cmake 0                                                                                                                                                                
/usr/bin/cmake -E cmake_progress_start /home/firstlove/projects/smallProjects/smalltools/findpath/build/CMakeFiles /home/firstlove/projects/smallProjects/smalltools/findpath/bu
ild/CMakeFiles/progress.marks                                                                                                                                                  
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
make -f CMakeFiles/path.dir/build.make CMakeFiles/path.dir/depend
make[2]: Entering directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
cd /home/firstlove/projects/smallProjects/smalltools/findpath/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/firstlove/projects/smallProjects/smalltools/findpa
th /home/firstlove/projects/smallProjects/smalltools/findpath /home/firstlove/projects/smallProjects/smalltools/findpath/build /home/firstlove/projects/smallProjects/smalltools
/findpath/build /home/firstlove/projects/smallProjects/smalltools/findpath/build/CMakeFiles/path.dir/DependInfo.cmake --color=                                                 
make[2]: Leaving directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
make -f CMakeFiles/path.dir/build.make CMakeFiles/path.dir/build
make[2]: Entering directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
[ 50%] Linking CXX executable path
/usr/bin/cmake -E cmake_link_script CMakeFiles/path.dir/link.txt --verbose=1
clang++     -fuse-ld=lld -stdlib=libc++ -lc++abi CMakeFiles/path.dir/findpath.cpp.o  -o path 
/usr/bin/ld.lld: error: undefined symbol: std::cout
>>> referenced by findpath.cpp
>>>               CMakeFiles/path.dir/findpath.cpp.o:(main)

/usr/bin/ld.lld: error: undefined symbol: std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<
char> >&, char const*)                                                                                                                                                         
>>> referenced by findpath.cpp
>>>               CMakeFiles/path.dir/findpath.cpp.o:(main)

/usr/bin/ld.lld: error: undefined symbol: std::ios_base::Init::Init()
>>> referenced by findpath.cpp
>>>               CMakeFiles/path.dir/findpath.cpp.o:(__cxx_global_var_init)

/usr/bin/ld.lld: error: undefined symbol: std::ios_base::Init::~Init()
>>> referenced by findpath.cpp
>>>               CMakeFiles/path.dir/findpath.cpp.o:(__cxx_global_var_init)
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/path.dir/build.make:84: path] Error 1
make[2]: Leaving directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/path.dir/all] Error 2
make[1]: Leaving directory '/home/firstlove/projects/smallProjects/smalltools/findpath/build'
make: *** [Makefile:84: all] Error 2

Oops, similar linker error…

Again, without cmake, it works fine:

~/.../smalltools/findpath >>> clang++ -stdlib=libc++ -lc++abi -std=c++17 -v -fuse-ld=lld findpath.cpp                                                            ±[A1●][master]
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/8.2.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/clang-6.0" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name findpath.cpp -mrelocation
-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 
-dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/clang/6.0.1 -internal-isystem /usr/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isyste
m /usr/lib/clang/6.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/firstlove/p
rojects/smallProjects/smalltools/findpath -ferror-limit 19 -fmessage-length 176 -stack-protector 2 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -f
color-diagnostics -o /tmp/findpath-671136.o -x c++ findpath.cpp                                                                                                                
clang -cc1 version 6.0.1 based upon LLVM 6.0.1 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../include/c++/v1
 /usr/local/include
 /usr/lib/clang/6.0.1/include
 /usr/include
End of search list.
 "/usr/bin/ld.lld" -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/Scrt
1.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/crtbeginS.o -L/usr/bin/../lib64/gcc/x86_64-pc-linux
-gnu/8.2.0 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-g
nu/8.2.0/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib -lc++abi /tmp/findpath-671136.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/
crtendS.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/crtn.o                                                                                             
~/.../smalltools/findpath >>>                                                                                                                                   ±[A1●●][master]
~/.../smalltools/findpath >>> ./a.out                                                                                                                           ±[A1●●][master]
Hi%

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Ld cannot find collect2 error ld returned 1 exit status
  • Lcpdfr encountered a critical error
  • Lcore exe системная ошибка
  • Lci ошибка самсунг на стиральной машине
  • Lcdm 2000 коды ошибок

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии