Skip to content

Commit

Permalink
sys-libs/compiler-rt-sanitizers: Add 16.0.0_pre20221113 snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Górny <[email protected]>
  • Loading branch information
mgorny committed Nov 13, 2022
1 parent 1f105d9 commit 2331889
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 0 deletions.
1 change: 1 addition & 0 deletions sys-libs/compiler-rt-sanitizers/Manifest
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ DIST llvm-project-15.0.3.src.tar.xz.sig 438 BLAKE2B e7e0614e144eb878f694c12e97cf
DIST llvm-project-15.0.4.src.tar.xz 110936424 BLAKE2B a02b76ad161e352b4d3d84baffdada9c6a0e704de7a2c4017df4d4d05a9e9d02113791cd7d91c3edfa1f5bcb7ab95e1772d60f7061514928c6828600f41a8322 SHA512 9d5b664dd77c08130601636f9d6c006b257f369470ce823aa56d06698a9f0edfec42f2c90da934b9ad52c4d7960d9a024ea46dc9640275be6d191b1ba9869459
DIST llvm-project-15.0.4.src.tar.xz.sig 566 BLAKE2B f1a7be65fcce932dc125ae2b498f68a14e68dad0d7a1e031343c52c5dafb7b123e346f3efa50a7693584361abf01efe9401b1b5781dee6b92dc1045e538e9b7b SHA512 35899ffbd13fc44cade54246a423450571cb4b62b8d706864daa3eef2377c48e24ef3113218e39e29de995b7f7fa307f9187552766576c9050fd924beb517f6e
DIST llvm-project-1fb186198af5f183dde053c1396f899567755d64.tar.gz 170328817 BLAKE2B c79199044e8d636127d1d163ceea856c1bcb1d59c892e9c72869ab788b4feb23f8c28585ac761764b4e29b883c61e43be9341610a523d8b64471200bb3aecfaa SHA512 8b366dc70506ceb70a5584ad051e100fa1cc620388fc757536ef775d102b4baaac016d4f62dbc8b1d9dd00b587622a25d9da735196d336faf35d611145cf5fdc
DIST llvm-project-f6f1fd443f48f417de9dfe23353055f1b20d87ef.tar.gz 170625743 BLAKE2B 3add45d7e2f26659f9602b5ccc034033610921ebeb2d6d69d6f5a3d1e3af224d3f5fd42e411d1fe0d5f8249c2ad995d41a236a87eba5a72ea9b20c112faa4c2f SHA512 2b57132d156f3d6d96802f617fff3eec0df6a3b5077ddcc4f31c87829e617f3065074d80e9d26c8c1c64322e76a09321fdfc8ae1d7a84f5da9f8606125e3b635
DIST llvmorg-13.0.1.tar.gz 147290251 BLAKE2B 2a44b012a672501761d0c27c6b3a315b69bfef0cd13b078a7e7d2fccc4a9c8c0f2bee0f164c4271c9106b0a99cb06e8b64986f66253b613336719fb86b82541b SHA512 9a8cb5d11964ba88b7624f19ec861fb28701f23956ea3c92f6ac644332d5f41fde97bd8933dd3ee70ed378058c252fa3a3887c8d1af90d219970c2b27691166f
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{8..11} )
inherit check-reqs cmake flag-o-matic llvm llvm.org python-any-r1

DESCRIPTION="Compiler runtime libraries for clang (sanitizers & xray)"
HOMEPAGE="https://llvm.org/"

LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
SLOT="${LLVM_MAJOR}"
KEYWORDS=""
IUSE="+abi_x86_32 abi_x86_64 +clang debug test"
# base targets
IUSE+=" +libfuzzer +memprof +orc +profile +xray"
# sanitizer targets, keep in sync with config-ix.cmake
# NB: ubsan, scudo deliberately match two entries
SANITIZER_FLAGS=(
asan dfsan lsan msan hwasan tsan ubsan safestack cfi scudo
shadowcallstack gwp-asan
)
IUSE+=" ${SANITIZER_FLAGS[@]/#/+}"
REQUIRED_USE="
|| ( ${SANITIZER_FLAGS[*]} libfuzzer orc profile xray )
test? (
cfi? ( ubsan )
gwp-asan? ( scudo )
)
"
RESTRICT="
!clang? ( test )
!test? ( test )
"

DEPEND="
sys-devel/llvm:${LLVM_MAJOR}
virtual/libcrypt[abi_x86_32(-)?,abi_x86_64(-)?]
"
BDEPEND="
>=dev-util/cmake-3.16
clang? ( sys-devel/clang )
elibc_glibc? ( net-libs/libtirpc )
test? (
!!<sys-apps/sandbox-2.13
$(python_gen_any_dep ">=dev-python/lit-15[\${PYTHON_USEDEP}]")
=sys-devel/clang-${LLVM_VERSION}*:${LLVM_MAJOR}
sys-libs/compiler-rt:${LLVM_MAJOR}
)
!test? (
${PYTHON_DEPS}
)
"

LLVM_COMPONENTS=( compiler-rt cmake llvm/cmake )
LLVM_TEST_COMPONENTS=( llvm/lib/Testing/Support third-party )
LLVM_PATCHSET=9999-1
llvm.org_set_globals

python_check_deps() {
use test || return 0
python_has_version ">=dev-python/lit-15[${PYTHON_USEDEP}]"
}

check_space() {
if use test; then
local CHECKREQS_DISK_BUILD=11G
check-reqs_pkg_pretend
fi
}

pkg_pretend() {
check_space
}

pkg_setup() {
check_space
LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup
python-any-r1_pkg_setup
}

src_prepare() {
sed -i -e 's:-Werror::' lib/tsan/go/buildgo.sh || die

local flag
for flag in "${SANITIZER_FLAGS[@]}"; do
if ! use "${flag}"; then
local cmake_flag=${flag/-/_}
sed -i -e "/COMPILER_RT_HAS_${cmake_flag^^}/s:TRUE:FALSE:" \
cmake/config-ix.cmake || die
fi
done

# TODO: fix these tests to be skipped upstream
if use asan && ! use profile; then
rm test/asan/TestCases/asan_and_llvm_coverage_test.cpp || die
fi
if use ubsan && ! use cfi; then
> test/cfi/CMakeLists.txt || die
fi

llvm.org_src_prepare
}

src_configure() {
# LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"

# pre-set since we need to pass it to cmake
BUILD_DIR=${WORKDIR}/compiler-rt_build

if use clang; then
local -x CC=${CHOST}-clang
local -x CXX=${CHOST}-clang++
strip-unsupported-flags
fi

local flag want_sanitizer=OFF
for flag in "${SANITIZER_FLAGS[@]}"; do
if use "${flag}"; then
want_sanitizer=ON
break
fi
done

local mycmakeargs=(
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
# use a build dir structure consistent with install
# this makes it possible to easily deploy test-friendly clang
-DCOMPILER_RT_OUTPUT_DIR="${BUILD_DIR}/lib/clang/${LLVM_MAJOR}"

-DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
# builtins & crt installed by sys-libs/compiler-rt
-DCOMPILER_RT_BUILD_BUILTINS=OFF
-DCOMPILER_RT_BUILD_CRT=OFF
-DCOMPILER_RT_BUILD_LIBFUZZER=$(usex libfuzzer)
-DCOMPILER_RT_BUILD_MEMPROF=$(usex memprof)
-DCOMPILER_RT_BUILD_ORC=$(usex orc)
-DCOMPILER_RT_BUILD_PROFILE=$(usex profile)
-DCOMPILER_RT_BUILD_SANITIZERS="${want_sanitizer}"
-DCOMPILER_RT_BUILD_XRAY=$(usex xray)

-DPython3_EXECUTABLE="${PYTHON}"
)

if use amd64; then
mycmakeargs+=(
-DCAN_TARGET_i386=$(usex abi_x86_32)
-DCAN_TARGET_x86_64=$(usex abi_x86_64)
)
fi

if use test; then
mycmakeargs+=(
-DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
-DLLVM_LIT_ARGS="$(get_lit_flags)"

# they are created during src_test()
-DCOMPILER_RT_TEST_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_MAJOR}/bin/clang"
-DCOMPILER_RT_TEST_CXX_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_MAJOR}/bin/clang++"
)

# same flags are passed for build & tests, so we need to strip
# them down to a subset supported by clang
CC=${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/clang \
CXX=${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/clang++ \
strip-unsupported-flags
fi

if use prefix && [[ "${CHOST}" == *-darwin* ]] ; then
mycmakeargs+=(
# setting -isysroot is disabled with compiler-rt-prefix-paths.patch
# this allows adding arm64 support using SDK in EPREFIX
-DDARWIN_macosx_CACHED_SYSROOT="${EPREFIX}/MacOSX.sdk"
# Set version based on the SDK in EPREFIX
# This disables i386 for SDK >= 10.15
# Will error if has_use tsan and SDK < 10.12
-DDARWIN_macosx_OVERRIDE_SDK_VERSION="$(realpath ${EPREFIX}/MacOSX.sdk | sed -e 's/.*MacOSX\(.*\)\.sdk/\1/')"
# Use our libtool instead of looking it up with xcrun
-DCMAKE_LIBTOOL="${EPREFIX}/usr/bin/${CHOST}-libtool"
)
fi

cmake_src_configure

if use test; then
local sys_dir=( "${EPREFIX}"/usr/lib/clang/${LLVM_MAJOR}/lib/* )
[[ -e ${sys_dir} ]] || die "Unable to find ${sys_dir}"
[[ ${#sys_dir[@]} -eq 1 ]] || die "Non-deterministic compiler-rt install: ${sys_dir[*]}"

# copy clang over since resource_dir is located relatively to binary
# therefore, we can put our new libraries in it
mkdir -p "${BUILD_DIR}"/lib/{llvm/${LLVM_MAJOR}/{bin,$(get_libdir)},clang/${LLVM_MAJOR}/include} || die
cp "${EPREFIX}"/usr/lib/llvm/${LLVM_MAJOR}/bin/clang{,++} \
"${BUILD_DIR}"/lib/llvm/${LLVM_MAJOR}/bin/ || die
cp "${EPREFIX}"/usr/lib/clang/${LLVM_MAJOR}/include/*.h \
"${BUILD_DIR}"/lib/clang/${LLVM_MAJOR}/include/ || die
cp "${sys_dir}"/*builtins*.a \
"${BUILD_DIR}/lib/clang/${LLVM_MAJOR}/lib/${sys_dir##*/}/" || die
# we also need LLVMgold.so for gold-based tests
if [[ -f ${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/LLVMgold.so ]]; then
ln -s "${EPREFIX}"/usr/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/LLVMgold.so \
"${BUILD_DIR}"/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/ || die
fi
fi
}

src_test() {
# respect TMPDIR!
local -x LIT_PRESERVES_TMP=1
# disable sandbox to have it stop clobbering LD_PRELOAD
local -x SANDBOX_ON=0
# wipe LD_PRELOAD to make ASAN happy
local -x LD_PRELOAD=

cmake_build check-all
}

0 comments on commit 2331889

Please sign in to comment.