-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler issue of multiple definition with libfolly.a and libstdc++.a #4072
Comments
Any comments for this? |
Dear @Sean58238 |
Below is my person note on build/debug from the nebula-dev container, with which, we could have build utilit/dep in isolated manner and can be used out of box, could you try with this instead, first? I used this container as a long run one, and it's pretty handy for me. Developing Env SetupNebula Graph assumed to be developed in GNU/Linux OS. The fastest yet clean way would be leveraging container(Docker, nerdctl, Podman etc...). Let's take docker as an example: First, clone the code and change to its path, and assuming we are working on v3.0.0 tag: git clone git@github.com:vesoft-inc/nebula.git
cd nebula
git checkout v3.0.0 Then, let's create a long-run Dev Container named # we create a docker network to enable future debugging on a Docker-Compose based Cluster
docker network create -d bridge nebula-docker-compose_nebula-net
export TAG=ubuntu2004
docker run -ti \
--network nebula-docker-compose_nebula-net \
--security-opt seccomp=unconfined \
-v "$PWD":/home/nebula \
-w /home/nebula \
--name nebula_$USER \
vesoft/nebula-dev:$TAG \
bash
# exit Everytime you would like to access it, just: docker start nebula_$USER
docker exec -ti nebula_$USER bash Build the source for the first time, note the first time build will take up to several hours. # access to dev docker if not yet
docker exec -ti nebula_$USER bash
mkdir build && cd build
cmake -DCMAKE_CXX_COMPILER=$TOOLSET_CLANG_DIR/bin/g++ -DCMAKE_C_COMPILER=$TOOLSET_CLANG_DIR/bin/gcc -DENABLE_WERROR=OFF -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=OFF ..
make -j64 # change 64 according to your cpu number
make install Check the built binaries, and nebula home: root@1827b82e88bf:/home/nebula/build# ls /usr/local/nebula/bin
db_dump db_upgrader meta_dump nebula-graphd nebula-metad nebula-storaged
root@1827b82e88bf:/home/nebula/build# ls /usr/local/nebula/
bin etc pids scripts share Debug Nebula GraphThis is an example on graphd. Let's assume we are working on the v3.0.0 Nebula Graph, otherwise, for example if it's the master branch, change to master according. Setup a Nebula ClusterRun a Nebula Graph Cluster with Docker Compose: git clone -b v3.0.0 https://github.com/vesoft-inc/nebula-docker-compose.git
cd nebula-docker-compose/
docker-compose up -d Access to the cluster and Activate Storage Services with docker run --rm -ti \
--network nebula-docker-compose_nebula-net \
--entrypoint=/bin/sh vesoft/nebula-console:v3.0.0
# Now we are in nebula-console(graphd CLI client) container
nebula-console -u root -p nebula --address=graphd --port=9669
# Now we are in nebula-conosle propmt
SHOW HOSTS;
ADD HOSTS "storaged0":9779,"storaged1":9779,"storaged2":9779;
SHOW HOSTS; Load the basketballplayer dataset into Nebula Graph from nebula-console :play basketballplayer;
# Dont panic, it will hang there for 1 minute to load them all.
# You will see somthing like this:
(root@nebula) [(none)]> :play basketballplayer;
Start loading dataset basketballplayer...
Load dataset succeeded! Exist the Console # exit the console prompt
exit
# exit the console container if you like to, you can stay here as you will come back soon.
exit Run a graphd with gdb
Access the docker exec -ti nebula_$USER bash Access the gdb cd /usr/local/nebula/
mkdir -p /home/nebula/build/log
gdb bin/nebula-graphd Set gdb variables, plese be noted, the set follow-fork-mode child
set args --flagfile=/usr/local/nebula/etc/nebula-graphd.conf.default \
--meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 \
--port=9669 \
--local_ip=nebula_tom \
--ws_ip=nebula_tom \
--ws_http_port=19669 \
--log_dir=/home/nebula/build/log \
--v=0 \
--minloglevel=0 Set a break function you would like to debug, here I will make it stop at the function: Then I will give b VidExtractVisitor::visit Then we could give a Connecting to the graphd running via gdbAccess to the nebula-console container docker run --rm -ti \
--network nebula-docker-compose_nebula-net \
--entrypoint=/bin/sh vesoft/nebula-console:v3.0.0 Run the console CLI binary, replace the nebula-console -u root -p nebula --address=nebula_tom --port=9669 Check graph hosts: > SHOW HOSTS GRAPH;
+--------------+------+-----------+---------+--------------+----------+
| Host | Port | Status | Role | Git Info Sha | Version |
+--------------+------+-----------+---------+--------------+----------+
| "graphd" | 9669 | "ONLINE" | "GRAPH" | "02b2091" | "v3.0.0" |
| "graphd" | 9669 | "ONLINE" | "GRAPH" | "02b2091" | "v3.0.0" |
| "graphd" | 9669 | "ONLINE" | "GRAPH" | "02b2091" | "v3.0.0" |
| "nebula_tom" | 9669 | "ONLINE" | "GRAPH" | "02b2091" | "v3.0.0" |
+--------------+------+-----------+---------+--------------+----------+ Give a query that may hit our breaking point, it should hang there. > MATCH (n) WHERE id(n) == "player100" RETURN n; Debug from GDBLet's back to the GDB window: (gdb) Below is an example of GDB. # f means to see current line
(gdb) f
#0 nebula::graph::VidExtractVisitor::visit (this=0x7fffd4df3800, expr=0x7fffd421ba00) at /home/nebula/src/graph/visitor/VidExtractVisitor.cpp:218
218 }
# l means to list surrounding code
(gdb) l
213 {{"", {VidPattern::Vids::Kind::kOtherSource, {}}}}};
214 } else {
215 vidPattern_ = VidPattern{};
216 }
217 }
218 }
219
220 void VidExtractVisitor::visit(SubscriptExpression *expr) {
221 UNUSED(expr);
222 vidPattern_ = VidPattern{};
# print variables of current scope
(gdb) print vidPattern_
$7 = {spec = nebula::graph::VidExtractVisitor::VidPattern::Special::kIgnore, nodes = {
_M_h = {<std::__detail::_Hashtable_base<std::__cxx11::basic_string<char,
...
# bt to query backtrace!
(gdb) bt
#0 nebula::graph::VidExtractVisitor::visit (this=0x7fffd4df3800, expr=0x7fffd421ba00) at /home/nebula/src/graph/visitor/VidExtractVisitor.cpp:218
#1 0x0000000004903272 in nebula::RelationalExpression::accept (this=0x7fffd421ba00, visitor=0x7fffd4df3800) at /home/nebula/src/common/expression/RelationalExpression.cpp:260
#2 0x0000000003568be2 in nebula::graph::VertexIdSeek::matchNode (this=0x7fffd42070a8, nodeCtx=0x7fffd4df3970) at /home/nebula/src/graph/planner/match/VertexIdSeek.cpp:40
#3 0x0000000003566957 in nebula::graph::StartVidFinder::match (this=0x7fffd42070a8, patternCtx=0x7fffd4df3970) at /home/nebula/src/graph/planner/match/StartVidFinder.cpp:13
...
# n to execute next line
(gdb) n
nebula::RelationalExpression::accept (this=0x7fffd421ba00, visitor=0x7fffd4df3800) at /home/nebula/src/common/expression/RelationalExpression.cpp:261
261 }
# s to step in a forloop or a function
(gdb)
# c to continue until next break point Changing codeModify the codeLet's say we are changing code, we actually just do it with your beloved editor inside the repo path, and it's not necessary to access the Dev Container. Build and Debug againBuildTo build on changed code base, we should access the container docker exec -ti nebula_$USER bash
# in the dev container
source /opt/vesoft/toolset/gcc/9.3.0/enable
cd build option: build and debug with unit test, note, this will consume more RAM: cmake -DCMAKE_CXX_COMPILER=$TOOLSET_CLANG_DIR/bin/g++ -DCMAKE_C_COMPILER=$TOOLSET_CLANG_DIR/bin/gcc -DENABLE_WERROR=OFF -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=ON ..
make -j64 # change 64 to other values based on your machine CPU count option: build without unit test: cmake -DCMAKE_CXX_COMPILER=$TOOLSET_CLANG_DIR/bin/g++ -DCMAKE_C_COMPILER=$TOOLSET_CLANG_DIR/bin/gcc -DENABLE_WERROR=OFF -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=OFF ..
make -j64 Debug with GDBLet's take graphd as an example, it's exactly the same as above chapters before changing code, docker exec -ti nebula_$USER bash
cd /usr/local/nebula/
mkdir -p /home/nebula/build/log
gdb bin/nebula-graphd
set follow-fork-mode child
set args --flagfile=/usr/local/nebula/etc/nebula-graphd.conf.default \
--meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 \
--port=9669 \
--local_ip=nebula_tom \
--ws_ip=nebula_tom \
--ws_http_port=19669 \
--log_dir=/home/nebula/build/log \
--v=0 \
--minloglevel=0
b VidExtractVisitor::visit
run |
Pls update latest third party lib. If if it still doesn't work, we continue to discuss it. Thanks. |
A compiler issue of multiple definition with libfolly.a and libstdc++.a as following
[ 69%] Building CXX object src/meta/CMakeFiles/meta_service_handler.dir/processors/schema/CreateEdgeProcessor.cpp.o
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_catch.o): In function
__cxa_begin_catch': (.text.__cxa_begin_catch+0x0): multiple definition of
__cxa_begin_catch'/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x2030): first defined here
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_catch.o): In function
__cxa_end_catch': (.text.__cxa_end_catch+0x0): multiple definition of
__cxa_end_catch'/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x1e60): first defined here
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_ptr.o): In function
std::rethrow_exception(std::__exception_ptr::exception_ptr)': (.text._ZSt17rethrow_exceptionNSt15__exception_ptr13exception_ptrE+0x0): multiple definition of
std::rethrow_exception(std::__exception_ptr::exception_ptr)'/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x1c60): first defined here
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_throw.o): In function
__cxa_throw': (.text.__cxa_throw+0x0): multiple definition of
__cxa_throw'/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x1990): first defined here
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_throw.o): In function
__cxa_rethrow': (.text.__cxa_rethrow+0x0): multiple definition of
__cxa_rethrow'/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x1b40): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [src/daemons/CMakeFiles/nebula-storaged.dir/build.make:634: bin/nebula-storaged] Error 1
make[1]: *** [CMakeFiles/Makefile2:6625: src/daemons/CMakeFiles/nebula-storaged.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
**Your Environments **
Steps to reproduce the behavior:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/nebula -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ..
make -j
The text was updated successfully, but these errors were encountered: