linker errors with WITH_UBSAN and WITH_ASAN

From: Kubilay Kocak <koobs_at_FreeBSD.org>
Date: Thu, 2 Sep 2021 11:35:12 +1000
Hi,

I'm seeing the following linker errors when using WITH_UBSAN (without 
WITH_ASAN) and WITH_ASAN (without WITH_UBSAN), having isolated other 
variables in src.conf and src-env.conf (attached below):

--- ftpd.full ---
ld: error: /usr/obj/usr/src/amd64.amd64/tmp/usr/lib/libmd.so: undefined 
reference to _libmd_SHA256_Transform [--no-allow-shlib-undefined]
cc: error: linker command failed with exit code 1 (use -v to see invocation)
_ERROR_CMD='cc -target x86_64-unknown-freebsd14.0 
--sysroot=/usr/obj/usr/src/amd64.amd64/tmp 
-B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin -march=sandybridge 
-mtune=sandybridge -O2 -pipe -fcolor-diagnostics -fno-common 
-march=sandybridge -DSETPROCTITLE -DLOGIN_CAP -DVIRTUAL_HOSTING 
-I/usr/src/libexec/ftpd -Dmain=ls_main -I/usr/src/bin/ls -DUSE_BLACKLIST 
-I/usr/src/contrib/blacklist/include -DINET6 -DUSE_PAM -fPIE 
-fsanitize=address -fPIC -fsanitize-recover=address -fsanitize=undefined 
-fsanitize-recover=undefined -g -gz=zlib -std=gnu99 
-Wno-format-zero-length -fstack-protector-strong -Wsystem-headers 
-Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign 
-Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable 
-Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality 
-Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef 
-Wno-address-of-packed-member -Wno-switch -Wno-switch-enum 
-Wno-knr-promoted-parameter -Qunused-arguments 
-L/usr/obj/usr/src/amd64.amd64/lib/libblacklist -pie -fsanitize=address 
-fsanitize=undefined 
-resource-dir=/usr/obj/usr/src/amd64.amd64/tmp/usr/lib/clang/12.0.1 
-Wl,--enable-new-dtags -Wl,-rpath,/usr/lib/ clang/12.0.1/lib/freebsd 
-o ftpd.full ftpd.o ftpcmd.o logwtmp.o popen.o ls.o cmp.o print.o util.o 
blacklist.o   -lcrypt  -lxo  -lutil  -lopie  -lmd  -lm  -lblacklist 
-lpam ;'

I believe Kyle (cc'd) may have identified the cause of it ("applying 
__attribute__((optnone)) to SHA256_Transform fixes it")

WITH_ASAN (without WITH_UBSAN), fails to link with the following errors:

--- all_subdir_usr.bin ---
--- all_subdir_usr.bin/clang/lldb ---
--- lldb.full ---
ld: error: undefined symbol: 
lldb_private::formatters::CMTimeSummaryProvider(lldb_private::ValueObject&, 
lldb_private::Stream&, lldb_private::TypeSummaryOptions const&)
 >>> referenced by memory:1265 
(/usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/memory:1265)
 >>>               ObjCLanguage.o:(void 
std::__1::__call_once_proxy<std::__1::tuple<lldb_private::ObjCLanguage::GetFormatters()::$_0&&> 
 >(void*)) in archive 
/usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: lldb_private::AppleObjCRuntimeV2::Initialize()
 >>> referenced by AppleObjCRuntime.cpp:60 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:60)
 >>> 
AppleObjCRuntime.o:(lldb_private::lldb_initialize_AppleObjCRuntime()) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by AppleObjCRuntime.cpp:60 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:60)
 >>> 
AppleObjCRuntime.o:(lldb_private::AppleObjCRuntime::Initialize()) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: lldb_private::AppleObjCRuntimeV1::Initialize()
 >>> referenced by AppleObjCRuntime.cpp:61 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:61)
 >>> 
AppleObjCRuntime.o:(lldb_private::lldb_initialize_AppleObjCRuntime()) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by AppleObjCRuntime.cpp:61 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:61)
 >>> 
AppleObjCRuntime.o:(lldb_private::AppleObjCRuntime::Initialize()) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: lldb_private::AppleObjCRuntimeV2::Terminate()
 >>> referenced by AppleObjCRuntime.cpp:65 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:65)
 >>> 
AppleObjCRuntime.o:(lldb_private::lldb_terminate_AppleObjCRuntime()) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by AppleObjCRuntime.cpp:65 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:65)
 >>> 
AppleObjCRuntime.o:(lldb_private::AppleObjCRuntime::Terminate()) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: lldb_private::AppleObjCRuntimeV1::Terminate()
 >>> referenced by AppleObjCRuntime.cpp:66 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:66)
 >>> 
AppleObjCRuntime.o:(lldb_private::lldb_terminate_AppleObjCRuntime()) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by AppleObjCRuntime.cpp:66 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:66)
 >>> 
AppleObjCRuntime.o:(lldb_private::AppleObjCRuntime::Terminate()) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: lldb_private::CFBasicHash::IsValid() const
 >>> referenced by NSSet.cpp:570 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSSet.cpp:570)
 >>> 
NSSet.o:(lldb_private::formatters::NSCFSetSyntheticFrontEnd::CalculateNumChildren()) 
in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by NSDictionary.cpp:712 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp:712)
 >>> 
NSDictionary.o:(lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::CalculateNumChildren()) 
in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: lldb_private::CFBasicHash::GetCount() const
 >>> referenced by NSSet.cpp:572 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSSet.cpp:572)
 >>> 
NSSet.o:(lldb_private::formatters::NSCFSetSyntheticFrontEnd::CalculateNumChildren()) 
in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by NSSet.cpp:315 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSSet.cpp:315)
 >>>               NSSet.o:(bool 
lldb_private::formatters::NSSetSummaryProvider<true>(lldb_private::ValueObject&, 
lldb_private::Stream&, lldb_private::TypeSummaryOptions const&)) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by NSSet.cpp:315 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSSet.cpp:315)
 >>>               NSSet.o:(bool 
lldb_private::formatters::NSSetSummaryProvider<false>(lldb_private::ValueObject&, 
lldb_private::Stream&, lldb_private::TypeSummaryOptions const&)) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced 3 more times

ld: error: undefined symbol: lldb_private::CFBasicHash::Update(unsigned 
long, lldb_private::ExecutionContextRef)
 >>> referenced by NSSet.cpp:588 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSSet.cpp:588)
 >>> 
NSSet.o:(lldb_private::formatters::NSCFSetSyntheticFrontEnd::Update()) 
in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by NSSet.cpp:313 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSSet.cpp:313)
 >>>               NSSet.o:(bool 
lldb_private::formatters::NSSetSummaryProvider<true>(lldb_private::ValueObject&, 
lldb_private::Stream&, lldb_private::TypeSummaryOptions const&)) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by NSSet.cpp:313 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSSet.cpp:313)
 >>>               NSSet.o:(bool 
lldb_private::formatters::NSSetSummaryProvider<false>(lldb_private::ValueObject&, 
lldb_private::Stream&, lldb_private::TypeSummaryOptions const&)) in 
archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced 3 more times

ld: error: undefined symbol: 
lldb_private::CFBasicHash::GetValuePointer() const
 >>> referenced by NSSet.cpp:598 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSSet.cpp:598)
 >>> 
NSSet.o:(lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetChildAtIndex(unsigned 
long)) in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
 >>> referenced by NSDictionary.cpp:742 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp:742)
 >>> 
NSDictionary.o:(lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::GetChildAtIndex(unsigned 
long)) in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: lldb_private::CFBasicHash::GetKeyPointer() 
const
 >>> referenced by NSDictionary.cpp:741 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp:741)
 >>> 
NSDictionary.o:(lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::GetChildAtIndex(unsigned 
long)) in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: 
lldb_private::lldb_renderscript::fixupX86_64FunctionCalls(llvm::Module&)
 >>> referenced by RenderScriptExpressionOpts.cpp:109 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp:109)
 >>> 
RenderScriptExpressionOpts.o:(RenderScriptRuntimeModulePass::runOnModule(llvm::Module&)) 
in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a

ld: error: undefined symbol: 
lldb_private::lldb_renderscript::fixupX86FunctionCalls(llvm::Module&)
 >>> referenced by RenderScriptExpressionOpts.cpp:101 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp:101)
 >>> 
RenderScriptExpressionOpts.o:(RenderScriptRuntimeModulePass::runOnModule(llvm::Module&)) 
in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
--- all_subdir_lib ---
Building 
/usr/obj/usr/src/amd64.amd64/lib/libarchive/tests/test_read_format_cpio_bin_gz.o
--- all_subdir_usr.sbin ---
Building /usr/obj/usr/src/amd64.amd64/usr.sbin/mld6query/mld6query.full
--- all_subdir_usr.bin ---
ld: error: undefined symbol: 
NewCommandObjectRenderScriptScriptGroup(lldb_private::CommandInterpreter&)
 >>> referenced by RenderScriptRuntime.cpp:4926 
(/usr/src/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp:4926)
 >>> 
RenderScriptRuntime.o:(CommandObjectRenderScriptRuntime::CommandObjectRenderScriptRuntime(lldb_private::CommandInterpreter&)) 
in archive /usr/obj/usr/src/amd64.amd64/lib/clang/liblldb/liblldb.a
--- all_subdir_usr.sbin ---
Building /usr/obj/usr/src/amd64.amd64/usr.sbin/mld6query/mld6query.debug


=============================================
src.conf:

MALLOC_PRODUCTION=yes
WITHOUT_LLVM_ASSERTIONS=yes

WITH_PIE=yes
WITH_BIND_NOW=yes
WITH_RETPOLINE=yes
WITH_SSP=yes

WITH_ASAN=yes
WITH_UBSAN=yes

WITH_CCACHE_BUILD=yes
CCACHE_PREFIX=/usr/local/bin/distcc

==============================================
src-env.conf:

WITH_META_MODE=yes
Received on Thu Sep 02 2021 - 01:35:12 UTC

Original text of this message