From nobody Tue Aug 22 12:08:31 2023 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RVSmf0vxPz4qpKX for ; Tue, 22 Aug 2023 12:08:34 +0000 (UTC) (envelope-from ronald@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RVSmf0Qykz3SVV; Tue, 22 Aug 2023 12:08:34 +0000 (UTC) (envelope-from ronald@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692706114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v6Pt/JDLYl0viZXWEqAaLHBM9fUjnf6C0ZCg9UCAqIE=; b=cEx+Tt322c0s2dWmJofwmum9+dvmvXRuFTiRprMeNpd4aQiVNzRRFjcrJGEHvRw1J5ywdG PTcsmPIsWNO8+erjlFcISgiDUbPRwOuyGgph1hLNNPc6HF2zLxck+aIbLc1Jkxw+uoNs1M XZ6Mu8TK8iRBNe/cvIYhyFpcoaaGtOK++Y5cL8s7gmWgOrH/499wj/Eda5dRTq45qJueJR 0335Ppj83UHsH7QAcr3PjG5S1oiAlkhVrC6xdF4lJNqwveMf6wBtKW2LNIf+nNeFh0umH+ AYR9V29PZRdZ7HGeT+6MUlC4GYdN5Jc6Og7TbWAqhI9n6cGYdI9BvO/gLz3iyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692706114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v6Pt/JDLYl0viZXWEqAaLHBM9fUjnf6C0ZCg9UCAqIE=; b=RLT23SNrYMAnoUunSbpr6lTkFawgfAhNXgCLA++mz5hsUxTJLicFTWb9t3VjC42yE+t/yW IhFlfXQhGh00aUGpCaOd/b1Q7bEOf009jWlpyYfCG1YIQAwE5bBzfsSatcHtN6bosVS15c 8YfwjIG1DB7lM2lhetPH79waFL+blTYZlLZ3wMyeC3Fdac9/yBj1an9YmL2iODARoZPyL6 KG5kjqbWwcymd3xG9m9+bmvRlAwZDUoB2e8tV7TxB47Rip06cEYhuu3kBP8CRwTb2RnIm3 06MY5opX03L0vvyUH9dmHs34e+I9uvcHpppbQHtdQ7G4cI/G6aGwroVzC7HScg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692706114; a=rsa-sha256; cv=none; b=hEaITy/4/TlbSPyYsdHefNwheCSpPyPLPdiUOXPr7K0B5OqSOEn8zYu6qctTkDHje/t5cD o70eINbVtmTCHHvduJ8hN0p8z/rSAfradWrKi/TLCS7y21UPM3XUySLVrXbos8Ib6omStH 4sz745WQXQoy0U6bYmSgIA/VQ0aLzvv7Sc+ejnuWB3fhq2nNFY+EWf440Ld5uZbZm1WjRT L3DsABYC+6GORTXuWhhoXIrXZMW1VvCazDyGAF3tblPglGy3T+Av88nnuZzQrZMCV8amKk Osk9dMpHIK/rsFfSTaGkp+6Lc1go9oEws97jEH6dTmTS8yFrx1CXfZwJQVlxZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from [IPV6:2001:1c00:2709:2010:749d:807f:4b36:6fb] (2001-1c00-2709-2010-749d-807f-4b36-06fb.cable.dynamic.v6.ziggo.nl [IPv6:2001:1c00:2709:2010:749d:807f:4b36:6fb]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: ronald/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RVSmd4Ycpz121G; Tue, 22 Aug 2023 12:08:33 +0000 (UTC) (envelope-from ronald@FreeBSD.org) Message-ID: Date: Tue, 22 Aug 2023 14:08:31 +0200 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: building with llvm16 pkg fails in tests From: Ronald Klop To: Brooks Davis Cc: freebsd-current@freebsd.org References: <76ecade1-3f42-a314-825d-6f1ba0b2dcaa@FreeBSD.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 8/19/23 22:28, Ronald Klop wrote: > On 8/17/23 21:33, 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::allocator> 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 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. >> >> -- Brooks > > > Hi, > > What I would like to accomplish is this: > > CROSS_TOOLCHAIN=llvm16 > WITHOUT_TOOLCHAIN=yes > > yes | make delete-old delete-old-libs > make buildworld buildkernel > > So I can run a system with only external toolchain. > But doing this quickly errors out because /usr/bin/cc does not exist and the build uses that even though CROSS_TOOLCHAIN is set. To circumvent that I set CC, etc. instead of CROSS_TOOLCHAIN. > > Regards, > Ronald. > Hi, I found what was going on. Passing CC=/usr/local/llvm16/bin/clang does not pass the -target, --sysroot and -B option. If I set those in CFLAGS everything compiles fine. What I do now is this: pkg -j ${JAIL_NAME} install -y ${CROSS_TOOLCHAIN} byacc jexec ${JAIL_NAME} sh -c "yes | /usr/bin/make CC=${LLVM_DIR}/bin/clang LD=${LLVM_DIR}/bin/ld.lld -C /usr/src delete-old delete-old-libs" cd ${JAIL_PATH}/usr/bin && ln -fs ../local/llvm16/bin/clang cc cd ${JAIL_PATH}/usr/bin && ln -fs ../local/llvm16/bin/clang CC cd ${JAIL_PATH}/usr/bin && ln -fs ../local/llvm16/bin/clang++ c++ cd ${JAIL_PATH}/usr/bin && ln -fs ../local/llvm16/bin/clang-cpp cpp cd ${JAIL_PATH}/usr/bin && ln -fs ../local/llvm16/bin/llvm-objcopy objcopy cd ${JAIL_PATH}/usr/bin && ln -fs ../local/llvm16/bin/ld cd ${JAIL_PATH}/usr/bin && ln -fs ../local/bin/yacc jexec ${JAIL_NAME} /usr/bin/make -C /usr/src -j${NUM_CPUS} CROSS_TOOLCHAIN=llvm16 WITHOUT_TOOLCHAIN=yes buildworld buildkernel This builds fine also. Because CC is not set SYSROOT is just the default. Any advice on how to make set CC and use the proper sysroot instead of the (ugly) symlinking? And why do parts of buildworld use CROSS_TOOLCHAIN and other parts don't? Regards, Ronald.