#babeltrace2: ELF binary /usr/lib/babeltrace2/plugins/babeltrace-plugin-text.so has relocations in .text [textrel]
TOOLCHAIN:pn-babeltrace2 = "gcc"
TOOLCHAIN:pn-u-boot = "gcc"
TOOLCHAIN:pn-cpufrequtils = "gcc"
# crash embeds version of gdb which is not buildable with clang
TOOLCHAIN:pn-crash = "gcc"
TOOLCHAIN:pn-elfutils = "gcc"

#| erl_bits.c:(.text+0xc2a): undefined reference to `__extendhfsf2'
#| erl_bits.c:(.text+0x1bfa): undefined reference to `__truncsfhf2'
#| clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
# both riscv64 and x86-64
TOOLCHAIN:pn-erlang = "gcc"

# /mnt/a/yoe/build/tmp/work/cortexa7t2hf-neon-vfpv4-yoe-linux-gnueabi/firefox/60.1.0esr-r0/recipe-sysroot-native/usr/lib/clang/7.0.1/include/arm_neon.h:433:1: error: unknown type name 'inline'
# __ai uint8x16_t vabdq_u8(uint8x16_t __p0, uint8x16_t __p1) {
TOOLCHAIN:pn-firefox = "gcc"
TOOLCHAIN:pn-gcc = "gcc"
TOOLCHAIN:pn-gcc-runtime = "gcc"
TOOLCHAIN:pn-gcc-sanitizers = "gcc"
TOOLCHAIN:pn-glibc = "gcc"
TOOLCHAIN:pn-glibc-initial = "gcc"
TOOLCHAIN:pn-glibc-locale = "gcc"
TOOLCHAIN:pn-glibc-mtrace = "gcc"
TOOLCHAIN:pn-glibc-scripts = "gcc"
TOOLCHAIN:pn-glibc-testsuite = "gcc"
TOOLCHAIN:pn-glibc-tests = "gcc"
TOOLCHAIN:pn-grub = "gcc"
TOOLCHAIN:pn-grub-efi = "gcc"

#| prelink-rtld: error while loading shared libraries: ld.so.1
#| /lib64/ld.so.1: No such file or directory
TOOLCHAIN:pn-gobject-intospection:mips64 = "gcc"
TOOLCHAIN:pn-avahi:mips64 = "gcc"

# VLAs
#| control.c:286:19: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
#|             __u32 buffer[cam->max_response_quads];
#|                   ^
#| 1 error generated.
TOOLCHAIN:pn-libdc1394 = "gcc"

# error: return address can be determined only for current frame
TOOLCHAIN:pn-libexecinfo:mipsarch = "gcc"
TOOLCHAIN:pn-libgcc = "gcc"
TOOLCHAIN:pn-libgcc-initial = "gcc"
TOOLCHAIN:pn-libgfortran = "gcc"
TOOLCHAIN:pn-libssp-nonshared = "gcc"

TOOLCHAIN:pn-m4:powerpc = "gcc"
# clang does not have 64bit atomics on ppc
TOOLCHAIN:pn-mesa:powerpc = "gcc"
# clang fails with db.c:(.text+0x188): unsupported bss-plt -fPIC ifunc mmio_write64_be
TOOLCHAIN:pn-rdma-core:powerpc = "gcc"
# usermode qemu crashes when running binaries from clang + rust compiler on ppc32
TOOLCHAIN:pn-librsvg:powerpc = "gcc"
# variant-impl.hpp:309:36: error: 'is_variant' does not name a template but is followed by template arguments
TOOLCHAIN:pn-omxplayer = "gcc"
# error: return address can be determined only for current frame
TOOLCHAIN:pn-openflow:mipsarch = "gcc"
TOOLCHAIN:pn-openjdk-8 = "gcc"
TOOLCHAIN:pn-openjre-8 = "gcc"
TOOLCHAIN:pn-syslinux = "gcc"
TOOLCHAIN:pn-systemtap = "gcc"
# v4l-utils uses nested functions
TOOLCHAIN:pn-v4l-utils = "gcc"
TOOLCHAIN:pn-valgrind = "gcc"
# uses C++ which clang does not like
TOOLCHAIN:pn-wvstreams = "gcc"
TOOLCHAIN:pn-wvdial = "gcc"
#| ../../mpfr-3.1.4/src/mul.c:324:11: error: invalid output constraint '=h' in asm
#|           umul_ppmm (tmp[1], tmp[0], MPFR_MANT (b)[0], MPFR_MANT (c)[0]);
TOOLCHAIN:pn-mpfr:mips = "gcc"
TOOLCHAIN:pn-mpfr:mips64 = "gcc"
#
#../../lib/libicui18n.so: undefined reference to `__atomic_fetch_sub_4'
#../../lib/libicui18n.so: undefined reference to `__atomic_load_4'
#../../lib/libicui18n.so: undefined reference to `__atomic_store_4'
#../../lib/libicui18n.so: undefined reference to `__atomic_fetch_add_4'
#
TOOLCHAIN:pn-icu:armv4 = "gcc"
TOOLCHAIN:pn-icu:armv5 = "gcc"

#../../libgcrypt-1.6.5/mpi/mpih-div.c:98:3: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
TOOLCHAIN:pn-libgcrypt:mips64 = "gcc"

#recipe-sysroot/usr/include/mozjs-60/mozilla/Span.h:634:5: error: statement not allowed in constexpr function
#|     MOZ_RELEASE_ASSERT(aStart <= len && (aLength == dynamic_extent ||
#|     ^
TOOLCHAIN:pn-polkit = "gcc"

# ppp uses nested functions and gcc specific option e.g. --print-sysroot
#
TOOLCHAIN:pn-ppp = "gcc"

#| ./ports/linux/pseudo_wrappers.c:80:14: error: use of unknown builtin '__builtin_apply' [-Wimplicit-function-declaration]
#|         void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
#|                     ^
#| ./ports/linux/pseudo_wrappers.c:80:57: error: use of unknown builtin '__builtin_apply_args' [-Wimplicit-function-declaration]
#|         void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
TOOLCHAIN:pn-pseudo = "gcc"

#| checking for multiarch... riscv64-yoe-linux
#| configure: error: internal configure error for the platform triplet, please file a bug report
TOOLCHAIN:pn-python3:riscv64 = "gcc"
TOOLCHAIN:pn-python3:riscv32 = "gcc"
TOOLCHAIN:pn-python3:libc-musl = "gcc"
# Use until OE-core merges https://lists.openembedded.org/g/openembedded-core/message/164192
TOOLCHAIN:pn-python3:aarch64 = "gcc"

# mix_neon.c:179:9: error: invalid operand in inline asm: 'vld1.s32 ${0:h}, [$2]
#      vld1.s32 ${1:h}, [$3] '
TOOLCHAIN:pn-pulseaudio:armv7ve = "gcc"
TOOLCHAIN:pn-pulseaudio:armv7a = "gcc"

# clang++ hangs see https://bugs.llvm.org/show_bug.cgi?id=45134
DEBUG_FLAGS:remove:pn-sqlite-orm:toolchain-clang = "-g"

#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:191: undefined reference to `__atomic_fetch_or_4'
#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:210: undefined reference to `__atomic_fetch_or_4'
#| libqemuutil.a(bitmap.o): In function `bitmap_test_and_clear_atomic':
#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:250: undefined reference to `__atomic_fetch_and_4'
#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:262: undefined reference to `__atomic_exchange_4'
#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:273: undefined reference to `__atomic_fetch_and_4'
# We need to link in with -latomic which comes from gcc-runtime anyway so just keep using gcc
# to compile qemu for target
TOOLCHAIN:pn-qemu:arm = "gcc"

#| ./dsp/v4f_IIR2.h:554:12: error: no matching function for call to 'v4f_map'
#|                                 a[5] = v4f_map<__builtin_cosf> (f);
#|                                        ^~~~~~~~~~~~~~~~~~~~~~~
TOOLCHAIN:pn-caps = "gcc"

# Fails to build with clang-13 errors with .export.sym file
#  Mismatch between symbols in shared library and lists in .exported_symbols.* files: dm_bit_get_prev
#TOOLCHAIN:pn-lvm2 = "gcc"
TOOLCHAIN:pn-libdevmapper = "gcc"

TOOLCHAIN:pn-lttng-ust:riscv64 = "gcc"

#| ../libffi-3.3-rc0/src/arm/sysv.S: Assembler messages:
#| ../libffi-3.3-rc0/src/arm/sysv.S:131: Error: selected processor does not support `vldrle d0,[sp]' in ARM mode
#| ../libffi-3.3-rc0/src/arm/sysv.S:132: Error: selected processor does not support `vldmgt sp,{d0-d7}' in ARM mode
TOOLCHAIN:pn-libffi:armeb = "gcc"

# Clang/mips still generates __sync_fetch_and_add_8 instead of __atomic_fetch_add_8 so it can't even use
# libatomic to provide these functions, therefore can not compile redis on mips
TOOLCHAIN:pn-redis:mips = "gcc"

# rocksdb/rocksdb/util/crc32c_ppc_asm.S:9:10: fatal error: 'ppc-asm.h' file not found
# #include <ppc-asm.h>
# This header is only available with gcc-cross
TOOLCHAIN:pn-mariadb:powerpc64le = "gcc"

# OpenCV does not compile for ppc64 with clang due to VSX clashes with altivec.h from clang
TOOLCHAIN:pn-opencv:powerpc64le = "gcc"
# Ade is used by openCV and shared C++ runtime so we can not mix libstdc++ and libc++
TOOLCHAIN:pn-ade:powerpc64le = "gcc"

# latest 32bit arch versions fails to compile with clang 13
# common/JackEngineControl.h:89:5: error: requested alignment is less than minimum alignment of 8 for type 'Jack::JackFrameTimer'
#|     alignas(UInt32) JackFrameTimer fFrameTimer;
#|     ^
TOOLCHAIN:pn-jack = "${@['clang','gcc'][d.getVar('SITEINFO_BITS') != '32']}"

#| error: return address can be determined only for current frame
#| error: return address can be determined only for current frame
#| error: return address can be determined only for current frame
TOOLCHAIN:pn-gcompat:mips = "gcc"

# Fixes Clang induced linker crashes when using glibc 2.35+
# mips-yoe-linux/mips-yoe-linux-ld: DWARF error: invalid or unhandled FORM value: 0x22
# mips-yoe-linux-ld: Zend/asm/make_mips32_o32_elf_gas.o: CALL16 reloc at 0x28 not against global symbol
# mips-yoe-linux/mips-yoe-linux-ld: BFD (GNU Binutils) 2.37.20210721 assertion fail ../../bfd/elfxx-mips.c:3614
TOOLCHAIN:pn-php:mips = "gcc"

CFLAGS:append:pn-liboil:toolchain-clang:x86-64 = " -fheinous-gnu-extensions "

#io_getevents.c:25:141: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
#io_syscall5(int, __io_getevents_0_4, io_getevents, io_context_t, ctx, long, min_nr, long, nr, struct io_event *, events, struct timespec *, timeout)
CFLAGS:append:pn-libaio:toolchain-clang:mips = " -fheinous-gnu-extensions"

#| error: unknown warning option '-Wimplicit-fallthrough=0'; did you mean '-Wimplicit-fallthrough'? [-Werror,-Wunknown-warning-option]
CFLAGS:append:pn-mdadm:toolchain-clang = " -Wno-error=unknown-warning-option"

#../libffi-3.2.1/src/arm/sysv.S:363:2: error: invalid instruction, did you mean: fldmiax?
# fldmiadgt ip, {d0-d7}
CFLAGS:append:pn-libffi:arm:toolchain-clang = " -no-integrated-as"
CFLAGS:append:pn-libffi:mips64:toolchain-clang = " -no-integrated-as"

# ../db-5.3.28/src/mutex/mut_tas.c:150:34: error: unknown directive
#<inline asm>:9:2: note: instantiated into assembly here
# .force_thumb
#        ^
#CFLAGS:append:pn-db:toolchain-clang = " -no-integrated-as"
#
#| ../../../DirectFB-1.7.7/lib/direct/armasm_memcpy.S:63:2: error: invalid instruction
#|  ldmgeia r1!, {r3, r4, r12, lr}
#|  ^
CFLAGS:append:pn-directfb:toolchain-clang:arm = " -no-integrated-as"

# Disable internal assembler for armv7 since it uses gnu assmebly syntax
# which should be preprocessed via gcc/compiler
#
CFLAGS:append:pn-openssl:toolchain-clang:armv7ve = " -no-integrated-as"
CFLAGS:append:pn-openssl:toolchain-clang:armv7a = " -no-integrated-as"

#| crypto/bn/bn-mips.S:671:2: error: unknown instruction, did you mean: bgeu, sgtu, tgeu?
#|  sgeu $1,$4,$6
#|  ^
CC:append:pn-openssl:toolchain-clang:mipsarch = " -no-integrated-as"

#| threads_pthread.c:(.text+0x372): undefined reference to `__atomic_is_lock_free'
EXTRA_OECONF:pn-openssl:toolchain-clang:x86 = "-latomic"

CFLAGS:append:pn-userland:toolchain-clang = " -no-integrated-as"

# libjpeg-turbo-2.0.2/simd/mips/jsimd_dspr2.S
# <instantiation>:13:5: error: invalid token in expression
# .if $17 != 0
# ^
CFLAGS:append:pn-libjpeg-turbo:toolchain-clang:mipsarch = " -no-integrated-as"

# arm-yoe-linux-gnueabi-ld: /usr/src/debug/libvorbis/1.3.6-r0/build/lib/../../libvorbis-1.3.6/lib/sharedbook.c:165: undefined reference to `__pow_finite'
CFLAGS:append:pn-libvorbis:toolchain-clang:armv7ve = " -fno-fast-math"
CFLAGS:append:pn-mpg123:toolchain-clang:armv7ve = " -fno-fast-math"

#../kexec-tools-2.0.18/purgatory/arch/i386/entry32-16.S:23:2: error: unknown directive
# .arch i386
# ^
CC:append:pn-kexec-tools:toolchain-clang:x86-64 = " -no-integrated-as"
CC:append:pn-kexec-tools:toolchain-clang:x86 = " -no-integrated-as"
CC:append:pn-kexec-tools-klibc:toolchain-clang:x86-64 = " -no-integrated-as"
CC:append:pn-kexec-tools-klibc:toolchain-clang:x86 = " -no-integrated-as"

#| /tmp/x86-sse2-cdb148.s:207:9: error: ambiguous operand size for instruction 'sub'
#|     sub SIZE, 64
#|         ^~~~
CFLAGS:append:pn-tinymembench:toolchain-clang:x86-64 = " -no-integrated-as"
CFLAGS:append:pn-tinymembench:toolchain-clang:x86 = " -no-integrated-as"
CFLAGS:append:pn-tinymembench:toolchain-clang:mipsarch = " -no-integrated-as"

CFLAGS:append:pn-ne10:toolchain-clang:arm = " -no-integrated-as"
CFLAGS:append:pn-libde265:toolchain-clang:arm = " -no-integrated-as"

# :5 :    error:    unknown directive
#^
#    .endfunc
#    ^
CFLAGS:append:pn-libsdl2:toolchain-clang:arm = " -no-integrated-as"

#2816:2: error: changed section type for .debug_frame, expected: 0x7000001E
# .section .debug_frame,"",@progbits
# ^
#lj_vm.S:2890:2: error: changed section flags for .eh_frame, expected: 0x2
# .section .eh_frame,"aw",@progbits
# ^
CFLAGS:append:pn-luajit:toolchain-clang:mips = " -no-integrated-as"

#FAILED: libucontext_posix.so.1
#clang-13: error: unable to execute command: Segmentation fault (core dumped)
#clang-13: error: linker command failed due to signal (use -v to see invocation)
CFLAGS:append:pn-libucontext:toolchain-clang:powerpc64le = " -no-integrated-as"

# Generated asm file can not be compiled with clang assembler due to presence of .0 label
# and its references
#| aes-decrypt-internal-2.s:368:1: error: unexpected token at start of statement
#| .0:
#| ^
CFLAGS:append:pn-nettle:toolchain-clang:powerpc64le = " -no-integrated-as"

# Fixes clang crash when compiling gnutls-3.7.2/lib/accelerated/aarch64/elf/sha512-armv8.s
CFLAGS:append:pn-gnutls:toolchain-clang:aarch64 = " -no-integrated-as"

# include/gcc/arm/ck_pr.h:201:1: error: instruction requires: arm-mode
#| CK_PR_DOUBLE_STORE(uint64_t, 64)
#| ^
#include/gcc/arm/ck_pr.h:192:6: note: expanded from macro 'CK_PR_DOUBLE_STORE'
#|                          "strexd        %1, %3, [%2]\n"         \
#|                           ^
CFLAGS:append:pn-concurrencykit:toolchain-clang:arm = " -no-integrated-as"

#../git/common/connection.c:154:55: error: comparison of integers of different signs: 'unsigned long' and 'int' [-Werror,-Wsign-compare]
#        for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
#                                                             ^~~~~~~~~~~~~~~~~~~~~~
CFLAGS:append:pn-seatd:toolchain-clang = " -Wno-sign-compare"

# regtest.cc:374:39: error: invalid suffix on literal; C++11 requires a
# space between literal and identifier [-Wreserved-user-defined-literal]
#|   snprintf_func (buf, sizeof(buf), "%"Q"u", x);
#|                                       ^

CXXFLAGS:append:pn-xdelta3:toolchain-clang = " -Wno-error=reserved-user-defined-literal"
# -fno-tree-vrp is gcc specific
CXXFLAGS:remove:pn-mozjs:toolchain-clang = "-fno-tree-vrp"
CFLAGS:remove:pn-mozjs:toolchain-clang = "-fno-tree-vrp"

#memcached.c:6280:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
CPPFLAGS:append:pn-memcached:toolchain-clang = " -Wno-error=embedded-directive"

#| /tmp/mcp2515-578c41.s: Assembler messages:
#| /tmp/mcp2515-578c41.s:1525: Error: r13 not allowed here -- `sub.w sp,r1,#8'
#| /tmp/mcp2515-578c41.s:1821: Error: r13 not allowed here -- `sub.w sp,r6,#8'
#| clang-7: error: assembler command failed with exit code 1 (use -v to see invocation)
TUNE_CCARGS:remove:pn-upm:toolchain-clang = "-no-integrated-as"
TUNE_CCARGS:remove:pn-omxplayer:toolchain-clang = "-no-integrated-as"
TUNE_CCARGS:remove:pn-nfs-utils:toolchain-clang = "-Qunused-arguments"

# We want to error out when -msse option is used otherwise it enables sse on non-x86 arches
TUNE_CCARGS:remove:pn-pipewire:toolchain-clang = "-Qunused-arguments"
TUNE_CCARGS:remove:pn-tesseract:toolchain-clang = "-Qunused-arguments"
TUNE_CCARGS:remove:pn-pulseaudio:toolchain-clang = "-Qunused-arguments"

# Disable altivec on ppc32
#/usr/include/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h:1345:32: error: use of undeclared identifier 'vec_sqrt'; did you mean 'vec_rsqrt'?
#  BF16_TO_F32_UNARY_OP_WRAPPER(vec_sqrt, a);
#                               ^~~~~~~~
#                               vec_rsqrt
TUNE_CCARGS:pn-ceres-solver:append:toolchain-clang:powerpc = " -mno-altivec"
TUNE_CCARGS:pn-opencv:append:toolchain-clang:powerpc = " -mno-altivec"
CXXFLAGS:pn-libeigen:append:toolchain-clang:powerpc = " -DEIGEN_ALTIVEC_DISABLE_MMA"

#| /usr/src/debug/ruby/2.5.1-r0/build/../ruby-2.5.1/process.c:7073: undefined reference to `__mulodi4'
#| clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
COMPILER_RT:pn-ruby:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:pn-python3:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:pn-m4:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:pn-cpio:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:pn-openssh:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:pn-webkitgtk:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:pn-wpewebkit:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:pn-python3-numpy:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:pn-mongodb:toolchain-clang:runtime-gnu = "-rtlib=compiler-rt ${UNWINDLIB}"
COMPILER_RT:remove:pn-m4:powerpc = "-rtlib=compiler-rt"
COMPILER_RT:remove:pn-ruby:powerpc = "-rtlib=compiler-rt"
COMPILER_RT:remove:pn-webkitgtk:powerpc = "-rtlib=compiler-rt"
COMPILER_RT:remove:pn-m4:armeb = "-rtlib=compiler-rt"
COMPILER_RT:remove:pn-ruby:armeb = "-rtlib=compiler-rt"
COMPILER_RT:remove:pn-webkitgtk:armeb = "-rtlib=compiler-rt"

# build/lib/libQt5Widgets.so: undefined reference to `__lshrti3'
# __lshrti3 is missing in libgcc
COMPILER_RT:pn-qtbase:toolchain-clang:riscv32 = "-rtlib=compiler-rt ${UNWINDLIB}"

LDFLAGS:append:pn-gnutls:toolchain-clang:riscv64 = " -latomic"
LDFLAGS:append:pn-harfbuzz:toolchain-clang:riscv64 = " -latomic"
LDFLAGS:append:pn-qtwebengine:toolchain-clang:runtime-gnu:x86 = " -latomic"
LDFLAGS:append:pn-qemu:toolchain-clang:x86 = " -latomic"

# glibc is built with gcc and hence encodes some libgcc specific builtins which are not found
# when doing static linking with clang using compiler-rt, so use libgcc
# undefined reference to `__unordtf2'
COMPILER_RT:pn-aufs-util:libc-glibc:toolchain-clang:x86 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-libhugetlbfs:libc-glibc:toolchain-clang:x86 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-tsocks:libc-glibc:toolchain-clang:x86 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-libc-bench:libc-glibc:toolchain-clang:x86 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-libc-bench:libc-glibc:toolchain-clang:x86-64 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-mpich:toolchain-clang:x86 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-mpich:toolchain-clang:x86-64 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-aufs-util:libc-glibc:toolchain-clang:x86-64 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-libhugetlbfs:libc-glibc:toolchain-clang:x86-64 = "-rtlib=libgcc --unwindlib=libgcc"
COMPILER_RT:pn-tsocks:libc-glibc:toolchain-clang:x86-64 = "-rtlib=libgcc --unwindlib=libgcc"

#(unwind.o): in function `__pthread_unwind':
#/usr/src/debug/glibc/2.29-r0/git/nptl/unwind.c:121: undefined reference to `_Unwind_ForcedUnwind'
#clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
COMPILER_RT:pn-aufs-util:libc-glibc:toolchain-clang:arm = "--unwindlib=libgcc"
COMPILER_RT:pn-libhugetlbfs:libc-glibc:toolchain-clang:arm = "--unwindlib=libgcc"
COMPILER_RT:pn-libc-bench:libc-glibc:toolchain-clang:arm = "--unwindlib=libgcc"

# Uses gcc for native tools, e.g. nsinstall and passes clang options which fails so
# let same compiler ( gcc or clang) be native/cross compiler
# | gcc: error: unrecognized command line option ‘-Qunused-arguments’
BUILD_CC:pn-nss:toolchain-clang = "clang -rtlib=libgcc -unwindlib=none"

# libnoprofile.c:19:5: error: expected parameter declarator
# int printf(const char *format, ...) {
#    ^
# error: non-constant-expression cannot be narrowed from type 'std::chrono::duration<
#long long, std::ratio<1, 1> >::rep' (aka 'long long') to '__time_t' (aka 'long') in initializer list
# [-Wc++11-narrowing]
CXXFLAGS:append:pn-apt:toolchain-clang = " -Wno-c++11-narrowing"
lcl_maybe_fortify:pn-apt:toolchain-clang = ""

# LTO
# Seems to use symver ASMs see https://stackoverflow.com/questions/46304742/how-to-combine-lto-with-symbol-versioning
# lib/puny_encode.c:136: multiple definition of `_idn2_punycode_encode'
LTO:pn-libidn2:toolchain-clang = ""

#libcairo.so: undefined reference to pthread_mutexattr_init [--no-allow-shlib-undefined]
LTO:pn-cairo:toolchain-clang = ""

# see https://bugs.llvm.org/show_bug.cgi?id=50443 this is in clang-13, until it is fixed do not use -O2
SELECTED_OPTIMIZATION:remove:pn-poke:toolchain-clang = "-O2"

# See https://github.com/llvm/llvm-project/issues/53722
SELECTED_OPTIMIZATION:remove:pn-libvorbis:mips:toolchain-clang = "-O2"
SELECTED_OPTIMIZATION:append:pn-libvorbis:mips:toolchain-clang = " -O0"
SELECTED_OPTIMIZATION:remove:pn-x264:mips:toolchain-clang = "-O2"
SELECTED_OPTIMIZATION:append:pn-x264:mips:toolchain-clang = " -O0"
SELECTED_OPTIMIZATION:remove:pn-dcadec:mips:toolchain-clang = "-O2"
SELECTED_OPTIMIZATION:append:pn-dcadec:mips:toolchain-clang = " -O0"
SELECTED_OPTIMIZATION:remove:pn-graphviz:mips:toolchain-clang = "-O2"
SELECTED_OPTIMIZATION:append:pn-graphviz:mips:toolchain-clang = " -O0"
# See https://github.com/llvm/llvm-project/issues/54044
SELECTED_OPTIMIZATION:remove:pn-fio:mips:toolchain-clang = "-O2"
SELECTED_OPTIMIZATION:append:pn-fio:mips:toolchain-clang = " -O0"

# See https://github.com/llvm/llvm-project/issues/54005
TOOLCHAIN:pn-qtlocation:mips = "gcc"
TOOLCHAIN:pn-python3-grpcio-tools:mips = "gcc"

# This works with gcc-ranlib wrapper only which expands $@ shell array,
# but it will fail if RANLIB was set to <cross>-ranlib or
# <cross>-llvn-ranlib has same behaviour
RANLIB:append:pn-tcf-agent:toolchain-clang = " $@"

# Subprocess output:mips-yoe-linux-llvm-objcopy: error: Link field value 22 in section .rel.dyn is not a symbol table
# also seen on riscv64 and x86-64
OBJCOPY:pn-linux-yocto:toolchain-clang = "${HOST_PREFIX}objcopy"
STRIP:pn-linux-yocto:toolchain-clang = "${HOST_PREFIX}strip"

# see https://github.com/llvm/llvm-project/issues/53948
OBJCOPY:pn-opensbi:toolchain-clang = "${HOST_PREFIX}objcopy"
OBJCOPY:pn-libc-bench:toolchain-clang = "${HOST_PREFIX}objcopy"
STRIP:pn-libc-bench:toolchain-clang = "${HOST_PREFIX}strip"
OBJCOPY:pn-aufs-util:toolchain-clang = "${HOST_PREFIX}objcopy"
STRIP:pn-aufs-util:toolchain-clang = "${HOST_PREFIX}strip"

# Depend on GNU objcopy option missing in llvm-objcopy
# llvm-objcopy: error: unknown argument '--section-alignment=512'
OBJCOPY:pn-systemd-boot:toolchain-clang = "${HOST_PREFIX}objcopy"

# See https://github.com/llvm/llvm-project/issues/53998
STRIP:pn-kexec-tools-klibc:mips:toolchain-clang = "${HOST_PREFIX}strip"

# See https://github.com/llvm/llvm-project/issues/53999
STRIP:pn-go-helloworld:mips:toolchain-clang = "${HOST_PREFIX}strip"
OBJCOPY:pn-go-helloworld:mips:toolchain-clang = "${HOST_PREFIX}objcopy"
STRIP:pn-gosu:mips:toolchain-clang = "${HOST_PREFIX}strip"
OBJCOPY:pn-gosu:mips:toolchain-clang = "${HOST_PREFIX}objcopy"

# see https://github.com/llvm/llvm-project/issues/54213
OBJDUMP:pn-libbsd:mips:toolchain-clang = "${HOST_PREFIX}objdump"

# Need OBJDUMP during do_package_qa which is set to llvm-objdump with meta-clang
# it might work with GNU objdump since it falls back to one from build host
DEPENDS:pn-linux-firmware:append:toolchain-clang = " clang-native"

# Needs for solving fopenmp issues
DEPENDS:append:pn-pixman:mips:toolchain-clang = " openmp"
#| ../pixman-0.40.0/pixman/pixman-arm-neon-asm.S:3625:1: note: while in macro instantiation
#| generate_bilinear_scanline_func pixman_scaled_bilinear_scanline_0565_0565_SRC_asm_neon, 0565, 0565, 1, 1, 28, BILINEAR_FLAG_UNROLL_4
#| ^
#| <instantiation>:134:1: error: unknown directive
#| .endfunc
#| ^
CFLAGS:append:pn-pixman:arm:toolchain-clang = " -no-integrated-as"

