Comments (5)
...and when I add -DCMAKE_BUILD_TYPE=Debug
, I also get:
[19/19] Linking CXX executable replxx-example-cxx-api
FAILED: replxx-example-cxx-api
: && /usr/lib/llvm/10/bin/clang++-10 -fsanitize=undefined -stdlib=libc++ -g -fsanitize=undefined -stdlib=libc++ CMakeFiles/replxx-example-cxx-api.dir/examples/cxx-api.cxx.o CMakeFiles/replxx-example-cxx-api.dir/examples/util.c.o -o replxx-example-cxx-api -Wl,-rpath,/home/jkt/temp/xx libreplxx-d.so.0.0.2 && :
/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: replxx-example-cxx-api: hidden symbol `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE11__recommendEm' isn't defined
/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: Bad value
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: cannot make progress due to previous errors.
I'm building stuff (other libraries and applications) with UBSAN just fine otherwise. Demangler says that this is:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__recommend(unsigned long)
This particular error goes away if I remove -stdlib=libc++
from CXXFLAGS
and LDFLAGS
.
from replxx.
You are using LD=clang-10
to link C++ code (this is the C compiler, not the C++ compiler).
I suggest trying LD=clang++-10
instead.
from replxx.
@doug-moen , there's just one LD
for linking both C and C++ code. I've never heard about setting LD
to g++
or to clang++
.
Anyway, I tried what you propose, and there's apparently no change on my test system:
jkt@kolibrik ~/temp/xx $ CC=clang-10 CXX=clang++-10 LD=clang++-10 CFLAGS='-fsanitize=undefined' CXXFLAGS='-fsanitize=undefined -stdlib=libc++' LDFLAGS='-fsanitize=undefined -stdlib=libc++' cmake -GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug ~/work/cesnet/gerrit/CzechLight/cla-sysrepo/submodules/dependencies/replxx && ninja -k 666
-- The CXX compiler identification is Clang 10.0.0
-- The C compiler identification is Clang 10.0.0
-- Check for working CXX compiler: /usr/lib/llvm/10/bin/clang++-10
-- Check for working CXX compiler: /usr/lib/llvm/10/bin/clang++-10 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/lib/llvm/10/bin/clang-10
-- Check for working C compiler: /usr/lib/llvm/10/bin/clang-10 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jkt/temp/xx
[0/2] Re-checking globbed directories...
[17/19] Linking C executable replxx-example-c-api
FAILED: replxx-example-c-api
: && /usr/lib/llvm/10/bin/clang-10 -fsanitize=undefined -g -fsanitize=undefined -stdlib=libc++ CMakeFiles/replxx-example-c-api.dir/examples/c-api.c.o CMakeFiles/replxx-example-c-api.dir/examples/util.c.o -o replxx-example-c-api -Wl,-rpath,/home/jkt/temp/xx libreplxx-d.so.0.0.2 && :
libreplxx-d.so.0.0.2: undefined reference to `__ubsan_handle_function_type_mismatch_v1'
libreplxx-d.so.0.0.2: undefined reference to `__ubsan_vptr_type_cache'
libreplxx-d.so.0.0.2: undefined reference to `__ubsan_handle_dynamic_type_cache_miss'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
[19/19] Linking CXX executable replxx-example-cxx-api
FAILED: replxx-example-cxx-api
: && /usr/lib/llvm/10/bin/clang++-10 -fsanitize=undefined -stdlib=libc++ -g -fsanitize=undefined -stdlib=libc++ CMakeFiles/replxx-example-cxx-api.dir/examples/cxx-api.cxx.o CMakeFiles/replxx-example-cxx-api.dir/examples/util.c.o -o replxx-example-cxx-api -Wl,-rpath,/home/jkt/temp/xx libreplxx-d.so.0.0.2 && :
/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: replxx-example-cxx-api: hidden symbol `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE11__recommendEm' isn't defined
/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: Bad value
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: cannot make progress due to previous errors.
Notice that the linker in the first call gets "somehow" set "to the C compiler" by the build system. Also, that first target is not C++ code, it's a C code if I'm aprsing its name correctly.
from replxx.
I see two errors in your build.
The first error happens when linking replxx-example-c-api, which is a C program, but it is being linked with a C++ library. The problem is that cmake is using the C compiler to link a C++ program. cmake is passing -fsanitize=undefined
to clang-10, and clang-10 thinks it is linking a C program, so it doesn't use the additional C++ library required for use with -fsanitize=undefined
for sanitizing undefined behaviour in C++ programs relating to vtables and dynamic types, which are C++ only features. That's what I think is happening.
To test my hypothesis about the first link error, you can take the linker command that cmake is running:
/usr/lib/llvm/10/bin/clang-10 -fsanitize=undefined -g -fsanitize=undefined -stdlib=libc++ CMakeFiles/replxx-example-c-api.dir/examples/c-api.c.o CMakeFiles/replxx-example-c-api.dir/examples/util.c.o -o replxx-example-c-api -Wl,-rpath,/home/jkt/temp/xx libreplxx-d.so.0.0.2
and you can modify this command to invoke clang++-10
instead of clang-10
. After running this command directly from your shell, I bet that the 3 undefined references to C++ symbols that you are currently seeing will go away.
How to configure cmake to use the C++ compiler to link replxx-example-c-api is a separate issue.
The second build error occurs when linking replxx-example-cxx-api
. You've already figured out that it is caused by using libc++ instead of the default.
from replxx.
Does replxx
code/build system has any action items for this issue?
from replxx.
Related Issues (20)
- replxx_add_color_completion() defined but not implemented HOT 2
- error: debug map object file ... has changed ... since this executable was linked, file will be ignored HOT 1
- stdin loses unbuffered setting during callbacks HOT 1
- Memory handling for replxx_add_completion() / replxx_add_color_completion() undocumented HOT 1
- Pressing enter right after incremental search doesn't show the accepted line HOT 2
- retrieve last line before EOF HOT 1
- Replxx submitted to Fedora HOT 2
- Prompt is not re-rendered when I press "up" HOT 1
- Multiline text with <tab> leads to crash HOT 4
- How to abort "input" in another thread? HOT 5
- Help: wired behavior of Ctrl-A HOT 2
- segmentation fault on down arrow keypress HOT 5
- How to break loop when user press CTRL+C or CTRL+D or CTRL+Z or ESC ? HOT 2
- Support the switch of beep.
- How to enable multiline HOT 1
- Support custom file descriptors
- Homebrew integration for mac
- Undo
- New warning from gcc 13
- Looks like Marcin Konarski died in November 2021 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from replxx.