Skip to content
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

Linking fail when build instrumented clang #1374

Open
hrtan99 opened this issue Nov 28, 2024 · 2 comments
Open

Linking fail when build instrumented clang #1374

hrtan99 opened this issue Nov 28, 2024 · 2 comments

Comments

@hrtan99
Copy link

hrtan99 commented Nov 28, 2024

I'm trying to build an instrumented clang according to the doc.

Build command I use:

cmake -S llvm -B build_instr -G Ninja \
-DLLVM_TARGETS_TO_BUILD=host \
-DLLVM_ENABLE_PROJECTS='clang' \
-DLLVM_BUILD_INSTRUMENTED=IR \
-DLLVM_BUILD_RUNTIME=No \
-DLLVM_USE_LINKER=mold \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=/home/tanhuiri/projects/llvm-project/build_dev/bin/clang \
-DCMAKE_CXX_COMPILER=/home/tanhuiri/projects/llvm-project/build_dev/bin/clang++ \
-DCMAKE_C_FLAGS='-O2 -fprofile-generate=clang_instr/ -fno-inline' \
-DCMAKE_CXX_FLAGS='-O2 -fprofile-generate=clang_instr/ -fno-inline'

The linking was failed:

[3450/3980] Linking CXX executable bin/bugpoint
FAILED: bin/bugpoint
: && /home/tanhuiri/projects/llvm-project/build_dev/bin/clang++ -O2 -fprofile-generate=clang_instr/ -fno-inline -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fprofile-generate="/home/tanhuiri/projects/llvm-project/build_instr/profiles" -O3 -DNDEBUG -fuse-ld=mold -Wl,--color-diagnostics -fprofile-generate="/home/tanhuiri/projects/llvm-project/build_instr/profiles"   -Wl,--export-dynamic tools/bugpoint/CMakeFiles/bugpoint.dir/BugDriver.cpp.o tools/bugpoint/CMakeFiles/bugpoint.dir/CrashDebugger.cpp.o tools/bugpoint/CMakeFiles/bugpoint.dir/ExecutionDriver.cpp.o tools/bugpoint/CMakeFiles/bugpoint.dir/ExtractFunction.cpp.o tools/bugpoint/CMakeFiles/bugpoint.dir/FindBugs.cpp.o tools/bugpoint/CMakeFiles/bugpoint.dir/Miscompilation.cpp.o tools/bugpoint/CMakeFiles/bugpoint.dir/OptimizerDriver.cpp.o tools/bugpoint/CMakeFiles/bugpoint.dir/ToolRunner.cpp.o tools/bugpoint/CMakeFiles/bugpoint.dir/bugpoint.cpp.o -o bin/bugpoint  -Wl,-rpath,"\$ORIGIN/../lib:"  lib/libLLVMX86AsmParser.a  lib/libLLVMX86CodeGen.a  lib/libLLVMX86Desc.a  lib/libLLVMX86Info.a  lib/libLLVMAnalysis.a  lib/libLLVMBitWriter.a  lib/libLLVMCodeGen.a  lib/libLLVMExtensions.a  lib/libLLVMCore.a  lib/libLLVMipo.a  lib/libLLVMIRReader.a  lib/libLLVMAggressiveInstCombine.a  lib/libLLVMInstCombine.a  lib/libLLVMInstrumentation.a  lib/libLLVMLinker.a  lib/libLLVMObjCARCOpts.a  lib/libLLVMScalarOpts.a  lib/libLLVMSupport.a  lib/libLLVMTarget.a  lib/libLLVMTargetParser.a  lib/libLLVMTransformUtils.a  lib/libLLVMVectorize.a  lib/libLLVMMCDisassembler.a  lib/libLLVMAsmPrinter.a  lib/libLLVMCFGuard.a  lib/libLLVMGlobalISel.a  lib/libLLVMIRPrinter.a  lib/libLLVMSelectionDAG.a  lib/libLLVMCodeGen.a  lib/libLLVMObjCARCOpts.a  lib/libLLVMCGData.a  lib/libLLVMTarget.a  lib/libLLVMCodeGenTypes.a  lib/libLLVMBitWriter.a  lib/libLLVMSandboxIR.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMScalarOpts.a  lib/libLLVMAggressiveInstCombine.a  lib/libLLVMInstCombine.a  lib/libLLVMFrontendOffloading.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMSymbolize.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMDebugInfoPDB.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  lib/libLLVMDebugInfoBTF.a  lib/libLLVMProfileInference.a  lib/libLLVMObject.a  lib/libLLVMIRReader.a  lib/libLLVMAsmParser.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryFormat.a  lib/libLLVMTargetParser.a  lib/libLLVMSupport.a  lib/libLLVMDemangle.a  -lrt  -ldl  -lm  /usr/lib/x86_64-linux-gnu/libz.so  /usr/lib/x86_64-linux-gnu/libzstd.so && :
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::block_begin() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCodeGen.a(MachineCycleAnalysis.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::MachineFunction> >::getParentCycle() [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::block_end() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCodeGen.a(MachineCycleAnalysis.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::MachineFunction> >::print(llvm::GenericSSAContext<llvm::MachineFunction> const&) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycleInfo<llvm::GenericSSAContext<llvm::Function> >::getFunction() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCodeGen.a(MachineCycleAnalysis.cpp.o):(__llvm_prf_data): llvm::GenericCycleInfo<llvm::GenericSSAContext<llvm::MachineFunction> >::print(llvm::GenericCycle<llvm::GenericSSAContext<llvm::MachineFunction> > const*) [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCodeGen.a(MachineCycleAnalysis.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::MachineFunction> >::isReducible() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycleInfo<llvm::GenericSSAContext<llvm::Function> >::getSSAContext() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::getDepth() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::getParentCycle() [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCodeGen.a(MachineCycleAnalysis.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::MachineFunction> >::getHeader() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::print(llvm::GenericSSAContext<llvm::Function> const&) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycleInfo<llvm::GenericSSAContext<llvm::Function> >::print(llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> > const*) [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCodeGen.a(MachineCycleAnalysis.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::MachineFunction> >::isEntry(llvm::MachineBasicBlock const*) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::isReducible() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::getHeader() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::isEntry(llvm::BasicBlock const*) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCodeGen.a(MachineCycleAnalysis.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::MachineFunction> >::contains(llvm::MachineBasicBlock const*) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::contains(llvm::BasicBlock const*) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCodeGen.a(MachineCycleAnalysis.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::MachineFunction> >::printEntries(llvm::GenericSSAContext<llvm::MachineFunction> const&) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::getParentCycle() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::blocks() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(CycleInfo.cpp.o):(__llvm_prf_data): llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::printEntries(llvm::GenericSSAContext<llvm::Function> const&) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(DebugProgramInstruction.cpp.o):(__llvm_prf_data): llvm::DbgRecordParamRef<llvm::DIExpression>::getAsMDNode() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(DebugProgramInstruction.cpp.o):(__llvm_prf_data): llvm::DbgRecordParamRef<llvm::DIExpression>::operator==(llvm::DbgRecordParamRef<llvm::DIExpression> const&) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(DebugProgramInstruction.cpp.o):(__llvm_prf_data): llvm::DbgRecordParamRef<llvm::DILabel>::getAsMDNode() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(DebugProgramInstruction.cpp.o):(__llvm_prf_data): llvm::DbgRecordParamRef<llvm::DILocalVariable>::getAsMDNode() const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
mold: error: lib/libLLVMCore.a(DebugProgramInstruction.cpp.o):(__llvm_prf_data): llvm::DbgRecordParamRef<llvm::DILocalVariable>::operator==(llvm::DbgRecordParamRef<llvm::DILocalVariable> const&) const [clone .local] refers to a discarded COMDAT section probably due to an ODR violation
@rui314
Copy link
Owner

rui314 commented Nov 28, 2024

What is the version of /home/tanhuiri/projects/llvm-project/build_dev/bin/clang++? Does this happen with a release version of LLVM?

@hrtan99
Copy link
Author

hrtan99 commented Nov 28, 2024

I'm using LLVM 20 with commit b83399eab603320d3c2998450f4ada83e7fe746c.

First, I build a clang using gcc with compiler-rt enabled in release mode, and then I try to use this clang to build an instrumented clang using same source tree in release mode, then the link error occurred.

With the default lld, there is no such error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants