Re: building with llvm16 pkg fails in tests

From: Brooks Davis <brooks_at_freebsd.org>
Date: Thu, 17 Aug 2023 20:00:10 UTC
On Thu, Aug 17, 2023 at 07:33:33PM +0000, Brooks Davis wrote:
> On Thu, Aug 17, 2023 at 12:45:06PM +0200, Ronald Klop wrote:
> > Hi,
> > 
> > To save time on my Raspberry Pi I would like to build FreeBSD using a llvm pkg instead of llvm in the tree.
> > 
> > My /etc/make.conf:
> > WITHOUT_TOOLCHAIN=yes
> > LD=/usr/local/llvm16/bin/ld.lld
> > CC=/usr/local/llvm16/bin/clang
> > CXX=/usr/local/llvm16/bin/clang++
> > CPP=/usr/local/llvm16/bin/clang-cpp
> > OBJCOPY=/usr/local/llvm16/bin/llvm-objcopy
> > 
> > #WITHOUT_CLEAN=yes
> > 
> > 
> > This fails in:
> > 
> > /usr/local/llvm16/bin/clang++ -O2 -pipe -fno-common -fPIE -Wno-format-zero-length -nobuiltininc -idirafter /usr/local/llvm16/lib/clang/16/include -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wdate-time -Wmissing-variable-declarations -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-parameter -O0 -g0 -Qunused-arguments -I/usr/obj/usr/src/amd64.amd64/tmp/usr/include/private -I/usr/src/contrib/googletest/googlemock/include -I/usr/src/contrib/googletest/googlemock -I/usr/src/contrib/googletest/googletest/include -I/usr/src/contrib/googletest/googletest -I/usr/obj/usr/src/amd64.amd64/tmp/usr/include/private -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -Wno-deprecated-copy -Wno-signed-unsigned-wchar -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -Wno-deprecated-copy -Wno-signed-unsigned-wchar -fPIE -std=c++14 -Wno-deprecated-copy -Wno-error=inconsistent-missing-override -Wno-error=missing-variable-declarations -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-c++11-extensions  -Wl,-zrelro -pie  --ld-path=/usr/local/llvm16/bin/ld.lld -o gmock-actions_test  gmock-actions_test.o -lprivategmock_main -lprivategmock -lprivategtest
> > ld.lld: error: undefined symbol: testing::internal::DeathTest::Create(char const*, testing::Matcher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>, char const*, int, testing::internal::DeathTest**)
> > >>> referenced by gmock-actions_test.cc
> > >>>               gmock-actions_test.o:(testing::(anonymous namespace)::BuiltInDefaultValueDeathTest_IsUndefinedForReferences_Test::TestBody())
> > >>> referenced by gmock-actions_test.cc
> > >>>               gmock-actions_test.o:(testing::(anonymous namespace)::BuiltInDefaultValueDeathTest_IsUndefinedForReferences_Test::TestBody())
> > >>> referenced by gmock-actions_test.cc
> > >>>               gmock-actions_test.o:(testing::(anonymous namespace)::BuiltInDefaultValueDeathTest_IsUndefinedForNonDefaultConstructibleType_Test::TestBody())
> > >>> referenced 4 more times
> > 
> > ld.lld: error: undefined symbol: testing::Expectation::Expectation(std::__1::shared_ptr<testing::internal::ExpectationBase> const&)
> > 
> > 
> > Any thoughts on how to fix this?
> > Compiling with the in tree llvm does work properly.
> 
> Did it work with exactly this git revision?  I suspect an issue with the
> recent google test update rather than an llvm16 issue.  Note that for
> every sync to github we build the tree with the llvm16 port (all be it
> on amd64 by default).
> 
> It's worth noting one difference between your configuration and the
> CI one:  We don't set CC and friends directly.  Instead we use
> CROSS_TOOLCHAIN=llvm16.

FYI, here's a build and boot of aarch64 with llvm16:
https://cirrus-ci.com/task/6710148899536896

-- Brooks