Re: git: 4dbc7835cdfc - main - mips: Turn off LLVM MIPS targets by default

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 14 Dec 2021 18:27:09 UTC
On 12/10/21 10:31 AM, Warner Losh wrote:
> The branch main has been updated by imp:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=4dbc7835cdfc8e3ae5e85c2b883874ab75a2dc42
> 
> commit 4dbc7835cdfc8e3ae5e85c2b883874ab75a2dc42
> Author:     Warner Losh <imp@FreeBSD.org>
> AuthorDate: 2021-12-10 18:31:07 +0000
> Commit:     Warner Losh <imp@FreeBSD.org>
> CommitDate: 2021-12-10 18:31:07 +0000
> 
>      mips: Turn off LLVM MIPS targets by default
>      
>      Now that MIPS isn't a recognized target for buildworld, move llvm mips
>      to off by default.
>      
>      Sponsored by:           Netflix
>      Reviewed by:            dim
>      Differential Revision:  https://reviews.freebsd.org/D33364

This breaks NO_CLEAN=yes builds in I think a lot of object files.  I first saw
it with llvm-ar.o getting link errors with a -j 8 build, but hit different ones
when doing a single-threaded build to get clean errors:

===> usr.bin/clang/clang (all)
c++ -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin -O2 -pipe -fno-common -I/usr/obj/usr/src/amd64.amd64/lib/clang/libclang -I/usr/obj/usr/src/amd64.amd64/lib/clang/libllvm -I/usr/src/contrib/llvm-project/clang/include -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_STATIC_ANALYZER -I/usr/src/lib/clang/include -I/usr/src/contrib/llvm-project/llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAVE_VCS_VERSION_INC -DNDEBUG -DLLVM_DEFAULT_TARGET_TRIPLE=\"x86_64-unknown-freebsd14.0\" -DLLVM_HOST_TRIPLE=\"x86_64-unknown-freebsd14.0\" -DDEFAULT_SYSROOT=\"\" -DLLVM_TARGET_ENABLE_AARCH64 -DLLVM_TARGET_ENABLE_ARM -DLLVM_TARGET_ENABLE_POWERPC -DLLVM_TARGET_ENABLE_RISCV -DLLVM_TARGET_ENABLE_X86 -DLLVM_NATIVE_ASMPARSER=LLVMInitializeX86AsmParser -DLLVM_NATIVE_ASMPRINTER=LLVMInitializeX86AsmPrinter -DLLVM_NATIVE_DISASSEMBLER=LLVMInitializeX86Disassembler -DLLVM_NATIVE_TARGET=LLVMInitializeX86Target -DLLVM_NATIVE_TARGETINFO=LLVMInitializeX86TargetInfo -DLLVM_NATIVE_TARGETMC=LLVMInitializeX86TargetMC -ffunction-sections -fdata-sections -gline-tables-only -Wno-format-zero-length -fstack-protector-strong -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-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 -Wno-parentheses -Qunused-arguments -fno-exceptions -fno-rtti -std=c++14 -stdlib=libc++ -Wno-c++11-extensions  -Wl,--gc-sections  -o clang.full  cc1_main.o cc1as_main.o cc1gen_reproducer_main.o driver.o /usr/obj/usr/src/amd64.amd64/lib/clang/libclang/libclang.a /usr/obj/usr/src/amd64.amd64/lib/clang/libllvm/libllvm.a  -lz  -lexecinfo  -lncursesw  -lpthread
ld: error: undefined symbol: LLVMInitializeMipsTargetInfo
>>> referenced by Targets.def:17 (/usr/src/lib/clang/include/llvm/Config/Targets.def:17)
>>>               cc1_main.o:(cc1_main(llvm::ArrayRef<char const*>, char const*, void*))
>>> referenced by Targets.def:17 (/usr/src/lib/clang/include/llvm/Config/Targets.def:17)
>>>               cc1as_main.o:(cc1as_main(llvm::ArrayRef<char const*>, char const*, void*))
>>> referenced by Targets.def:17 (/usr/src/lib/clang/include/llvm/Config/Targets.def:17)
>>>               driver.o:(main)

ld: error: undefined symbol: LLVMInitializeMipsTarget
>>> referenced by Targets.def:17 (/usr/src/lib/clang/include/llvm/Config/Targets.def:17)
>>>               cc1_main.o:(cc1_main(llvm::ArrayRef<char const*>, char const*, void*))
>>> referenced by Targets.def:17 (/usr/src/lib/clang/include/llvm/Config/Targets.def:17)
>>>               driver.o:(main)

ld: error: undefined symbol: LLVMInitializeMipsTargetMC
>>> referenced by Targets.def:17 (/usr/src/lib/clang/include/llvm/Config/Targets.def:17)
>>>               cc1_main.o:(cc1_main(llvm::ArrayRef<char const*>, char const*, void*))
>>> referenced by Targets.def:17 (/usr/src/lib/clang/include/llvm/Config/Targets.def:17)
>>>               cc1as_main.o:(cc1as_main(llvm::ArrayRef<char const*>, char const*, void*))

ld: error: undefined symbol: LLVMInitializeMipsAsmPrinter
>>> referenced by AsmPrinters.def:17 (/usr/src/lib/clang/include/llvm/Config/AsmPrinters.def:17)
>>>               cc1_main.o:(cc1_main(llvm::ArrayRef<char const*>, char const*, void*))

ld: error: undefined symbol: LLVMInitializeMipsAsmParser
>>> referenced by AsmParsers.def:17 (/usr/src/lib/clang/include/llvm/Config/AsmParsers.def:17)
>>>               cc1_main.o:(cc1_main(llvm::ArrayRef<char const*>, char const*, void*))
>>> referenced by AsmParsers.def:17 (/usr/src/lib/clang/include/llvm/Config/AsmParsers.def:17)
>>>               cc1as_main.o:(cc1as_main(llvm::ArrayRef<char const*>, char const*, void*))
c++: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.

The problem I think is that the AsmParsers.def and Targets.def files don't actually change
contents when the list of targets changes, instead only the post-cpp contents so there's no
way for make to automatically realize it needs to rebuild any object files that include
those headers.

Perhaps we should be generating those header files in OBJDIR (and use a move-if-changed
scheme to avoid bumping the date if the contents haven't changed) so that make can handle
these changes?

-- 
John Baldwin