{% extends '//builtin/bag.ym' %} {% block current_version %}19.1.7{% endblock %} {% block current_url %} https://github.com/llvm/llvm-project/releases/download/llvmorg-{{self.version().strip()}}/compiler-rt-{{self.version().strip()}}.src.tar.xz {% endblock %} {% block patch_source %} ( rm CMakeLists.txt cd lib/builtins rm CMakeLists.txt rm aarch64/lse.S sed -e 's|.*#include.*sys/byteorder.h.*||' -i int_endianness.h sed -e 's|.*#include.*zircon/features.h.*||' -i cpu_model/aarch64/fmv/fuchsia.inc sed -e 's|.*#include.*zircon/features.h.*||' -i cpu_model/aarch64/lse_atomics/fuchsia.inc ) {% endblock %} {% block ya_make %} SUBSCRIBER( g:contrib g:cpp-contrib ) # Check MUSL before NO_PLATFORM() disables it. IF (MUSL) # We use C headers despite NO_PLATFORM, but we do not propagate # them with ADDINCL GLOBAL because we do not have an API, and we # can not propagate them because libcxx has to put its own # includes before musl includes for its include_next to work. IF (ARCH_X86_64) ADDINCL( contrib/libs/musl/arch/x86_64 ) ENDIF() IF (ARCH_AARCH64) ADDINCL( contrib/libs/musl/arch/aarch64 ) ENDIF() ADDINCL( contrib/libs/musl/arch/generic contrib/libs/musl/include contrib/libs/musl/extra ) ENDIF() NO_UTIL() NO_RUNTIME() NO_PLATFORM() NO_COMPILER_WARNINGS() IF (GCC OR CLANG) # Clang (maybe GCC too) LTO code generator leaves the builtin calls unresolved # even if they are available. After the code generation pass is done # a linker is forced to select original object files from this library again # as they contain unresolved symbols. But code generation is already done, # object files actually are not ELFs but an LLVM bytecode and we get # "member at xxxxx is not an ELF object" errors from the linker. # Just generate native code from the beginning. NO_LTO() ENDIF() {% endblock %} {% block gen_ya_make %} ( cd lib/builtins cat << EOF > join.py import os import sys common = open(sys.argv[1]).read().strip().split('\n') special = open(sys.argv[2]).read().strip().split('\n') arch = sys.argv[3] def name(n): return os.path.basename(n).split('.')[0] sset = frozenset([name(x) for x in special]) scrt = frozenset(['crtbegin', 'crtend']) # x86_80_BIT_SOURCES x86_not_win = frozenset(['divxc3', 'extendxftf2', 'fixxfdi', 'fixxfti', 'fixunsxfdi', 'fixunsxfsi', 'fixunsxfti', 'floatdixf', 'floattixf', 'floatundixf', 'floatuntixf', 'mulxc3', 'powixf2', 'trunctfxf2']) other_not_emscripten = frozenset([ 'clear_cache', 'emutls', 'enable_execute_stack', 'eprintf', ]) def it_srcs(): for x in common: n = name(x) if n.startswith("atomic_") or n.endswith("bf2") or n == "extendbfsf2": # these are handled explicitly below continue if n in scrt: continue if arch != 'x86_64_not_win' and n in x86_not_win: continue if arch == 'x86_64_not_win' and (not n in x86_not_win or n in ['floatdixf', 'floatundixf']): continue if arch == 'other' and n in other_not_emscripten: continue if arch == 'other_not_emscripten' and (n not in other_not_emscripten): continue if n not in sset: yield x yield from set(special) - {'x86_64/floatdixf.c', 'aarch64/sme-libc-routines.c'} print('\n'.join(sorted(list(it_srcs()))).strip()) EOF ls *.c > common cat << EOF IF (OS_DARWIN OR OS_IOS) SRCS( atomic_flag_clear.c atomic_flag_clear_explicit.c atomic_flag_test_and_set.c atomic_flag_test_and_set_explicit.c atomic_signal_fence.c atomic_thread_fence.c ) ENDIF() IF (ARCH_ARM64 OR ARCH_X86_64) # As of r25b, clang-for-android does not have bf16 support. # These can be built using r27 and above. IF (NOT OS_ANDROID) SRCS( # NB: sources that were commented out were added in llvm-20 extendbfsf2.c truncdfbf2.c # truncxfbf2.c truncsfbf2.c # trunctfbf2.c ) ENDIF() ENDIF() EOF echo 'IF (ARCH_AARCH64)' echo 'SRCS(' ls aarch64/*.c cpu_model/aarch64.*c aarch64/*.S > special python3 join.py common special aarch echo ')' echo 'IF(NOT OS_DARWIN) SRCS(aarch64/sme-libc-routines.c) ENDIF()' echo 'ELSEIF (ARCH_X86_64)' echo 'SRCS(' ls x86_64/*.c cpu_model/x86.*c x86_64/*.S > special python3 join.py common special x86_64 echo ')' # As llvm/compiler-rt/lib/builtins says: # Implement extended-precision builtins, assuming long double is 80 bits. # long double is not 80 bits on Android or MSVC. echo 'IF(NOT OS_WINDOWS AND NOT OS_ANDROID) SRCS(x86_64/floatdixf.c' echo '' > special python3 join.py common special x86_64_not_win echo ') ENDIF()' echo 'ELSE()' echo 'SRCS(' echo '' > special python3 join.py common special other echo ')' echo 'IF (NOT OS_EMSCRIPTEN)' echo 'SRCS(' python3 join.py common special other_not_emscripten echo ')' echo 'ENDIF()' echo 'ENDIF()' echo 'IF(OS_LINUX AND NOT WITH_MAPKIT)' echo 'SRCS(crtbegin.c crtend.c)' echo 'ENDIF()' rm join.py common special ) >> ya.make {% endblock %} {% block move_to_output %} {{super()}} cp -R lib/builtins/* ${OUTPUT}/ {% endblock %} {% block run_license_analyzer %} {{super()}} sed -e 's|.* LLVM.*||' -i ${OUTPUT}/ya.make {% endblock %}