From 8530ea4eafd68d8629da1b5fbaf2ccf4c9ed9e76 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Fri, 18 Oct 2019 03:25:53 +0200 Subject: [PATCH] clang recipe modifications and new scripts --- clang/clang | 52 +++++++++++++++++++++++++++++++++++++++++++ clang/labs.h | 7 ++++++ clang/recipe.spec | 28 ++++++++++++++++++++--- clang/wrapper-clang++ | 8 +++++++ clang/x86_64.cfg | 4 ++++ 5 files changed, 96 insertions(+), 3 deletions(-) create mode 100755 clang/clang create mode 100644 clang/labs.h create mode 100644 clang/wrapper-clang++ create mode 100644 clang/x86_64.cfg diff --git a/clang/clang b/clang/clang new file mode 100755 index 0000000..0bd85b8 --- /dev/null +++ b/clang/clang @@ -0,0 +1,52 @@ +#!/bin/sh + +requires_linking="true" +is_cpp=false + +if [ "$(basename $0)" = "clang++" ]; then + is_cpp=true +fi + +for i; do + case "$i" in + -c) + requires_linking="false" + ;; + -std=*) + std="$(printf "%s" "$i" | sed 's:-std=::')" + + if echo "$std" | grep -E -q '(c\+\+|gnu\+\+)'; then + is_cpp=true + else + is_cpp=false + fi + ;; + esac +done + +cpp_flags= +if $is_cpp; then + cpp_flags=" + -cxx-isystem /usr/weirdos/lib/c++/v1 + " +fi + +linker_flags= +if $requires_linking; then + linker_flags=" + -L /usr/weirdos/lib + -L /usr/weirdos/lib/gcc/x86_64-weird-linux-musl/9.1.0/ + -B /usr/weirdos/lib/gcc/x86_64-weird-linux-musl/9.1.0/ + -Wl,--dynamic-linker /lib/ld-musl-x86_64.so.1 + " + + if $is_cpp; then + cpp_flags="$cpp_flags -lc++ -lc++abi" + fi +fi + +clang-8 \ + -isystem /usr/weirdos/include/ \ + $linker_flags \ + $cpp_flags \ + "$@" diff --git a/clang/labs.h b/clang/labs.h new file mode 100644 index 0000000..3dbde5c --- /dev/null +++ b/clang/labs.h @@ -0,0 +1,7 @@ +#include + +namespace std { + static inline long abs(long a) { return std::labs(a); } + static inline long long abs(long long a) { return std::labs(a); } +} + diff --git a/clang/recipe.spec b/clang/recipe.spec index 605a4eb..6eeb74f 100644 --- a/clang/recipe.spec +++ b/clang/recipe.spec @@ -1,14 +1,36 @@ name: clang version: 8.0.1 release: 1 -sources: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/cfe-%{version}.src.tar.xz +sources: + - https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/cfe-%{version}.src.tar.xz + - labs.h + - clang + dirname: build @configure + #sed -i '/^ return ToolChain::CST_Libstdcxx/s@stdcxx@cxx@' cfe-%{version}.src/tools/lib/Driver/ToolChain.cpp mkdir %{dirname} cd %{dirname} cmake ../cfe-%{version}.src \ - -DCMAKE_PREFIX_PATH=/usr/bad/llvm-8 \ - -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_PREFIX_PATH=%{prefix} \ + -DCMAKE_INSTALL_PREFIX=%{prefix} \ + -DCLANG_CONFIG_FILE_SYSTEM_DIR=%{prefix}/etc/clang \ + -DCLANG_DEFAULT_CXX_STDLIB=libc++ \ + -DCMAKE_CXX_COMPILER="clang++" \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS -stdlib=libc++ -include /usr/weirdos/include/c++/v1/math.h -include $(pwd)/../labs.h -D__DEFINED_max_align_t" \ + -DCMAKE_C_COMPILER="clang" \ + -DCMAKE_C_FLAGS="$CFLAGS" \ + -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS -lc++" \ + -DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS -lc++" \ -DCMAKE_BUILD_TYPE=Release + +@install + cd %{dirname} + make DESTDIR=%{pkg} install + mkdir -p %{pkg}/prefix/bin + rm %{pkg}%{prefix}/bin/clang + cp ../clang %{pkg}%{prefix}/bin/ + rm %{pkg}%{prefix}/bin/clang++ + ln -s %{prefix}/bin/clang %{pkg}%{prefix}/bin/clang++ diff --git a/clang/wrapper-clang++ b/clang/wrapper-clang++ new file mode 100644 index 0000000..dd6c100 --- /dev/null +++ b/clang/wrapper-clang++ @@ -0,0 +1,8 @@ +#!/bin/sh + +clang-8 -L %{prefix}/lib \ + -L %{prefix}/lib/gcc/x86_64-weird-linux-musl/9.1.0/ \ + -B %{prefix}/lib/gcc/x86_64-weird-linux-musl/9.1.0/ \ + -Wl,--dynamic-linker /lib/ld-musl-x86_64.so.1 \ + -isystem %{prefix}/include/ \ + "$@" diff --git a/clang/x86_64.cfg b/clang/x86_64.cfg new file mode 100644 index 0000000..0fde10c --- /dev/null +++ b/clang/x86_64.cfg @@ -0,0 +1,4 @@ +-L /usr/weirdos/lib/gcc/x86_64-weird-linux-musl/9.1.0/ +-B /usr/weirdos/lib/gcc/x86_64-weird-linux-musl/9.1.0/ +-Wl,--dynamic-linker /lib/ld-musl-x86_64.so.1 +-I /usr/weirdos/include/