#!/usr/bin/make -f # polly & lldb aren't enabled for every platform PROJECTS = clang;clang-tools-extra;lld;cross-project-tests;mlir # openmp & libunwind aren't enabled for every platform TARGET_BUILD := build-llvm TARGET_BUILD_STAGE2 := $(TARGET_BUILD)/tools/clang/stage2-bins DEB_INST := $(CURDIR)/debian/tmp/ GXX_VERSIONED_PACKAGE := $(shell dpkg-query -W -f '$${Depends}' g++ | grep -o 'g++-[0-9][0-9.]*' | tail -n1 ) GXX_VERSIONED_EXECUTABLE := $(shell dpkg -L $(GXX_VERSIONED_PACKAGE) | grep '/usr/bin/g++-[0-9][0-9.]*' | xargs ls -d | tail -n1 ) GCC_VERSION := $(subst /usr/bin/g++-,,$(GXX_VERSIONED_EXECUTABLE)) PKG_VERSION := $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}') LLVM_EPOCH := 1: LLVM_VERSION := $(shell echo $(PKG_VERSION) | sed -rne "s,^1:([0-9]+).*,\1,p") LLVM_VERSION_FULL := $(shell echo $(PKG_VERSION) | sed -rne "s,^1:([0-9.]+)(~|-)(.*),\1,p") LLVM_VERSION_MINOR := $(shell echo $(PKG_VERSION) | sed -rne "s,^1:[0-9]+\.([0-9]+)\.[0-9]+.*,\1,p") LLVM_VERSION_SNAPSHOT := $(shell echo $(PKG_VERSION) | sed -rne "s,^1:(.*),\1,p") ifeq ($(LLVM_VERSION),$(LLVM_VERSION_FULL)) LLVM_VERSION_FULL := $(LLVM_VERSION).0.0 LLVM_VERSION_MINOR := 0 endif LLVM_VERSION_NEXT := $(shell echo $(LLVM_VERSION_FULL) | awk -F. '{ OFS="."; $$NF+=1; print}') # dpkg-buildflags support # disable fixfilepath in favor of the llvm-project supplied flavor, disable lto # remove +time64,+lfs once the time64_t transition starts ifeq ($(DEB_HOST_ARCH_CPU),i386) RUNTIMES = compiler-rt;libcxx;libcxxabi export DEB_BUILD_MAINT_OPTIONS = reproducible=-fixfilepath,-fixdebugpath optimize=-lto else RUNTIMES = compiler-rt;libcxx;libcxxabi ifeq ($(DEB_HOST_ARCH_BITS),32) export DEB_BUILD_MAINT_OPTIONS = reproducible=-fixfilepath,-fixdebugpath optimize=-lto abi=+time64,+lfs else ifeq ($(DEB_HOST_ARCH),mips64el) export DEB_BUILD_MAINT_OPTIONS = reproducible=-fixfilepath,-fixdebugpath optimize=-lto hardening=-stackprotector,-stackprotectorstrong else export DEB_BUILD_MAINT_OPTIONS = reproducible=-fixfilepath,-fixdebugpath optimize=-lto endif endif endif SOURCE_NAME := $(shell dpkg-parsechangelog -S Source) ifneq (,$(findstring snapshot,$(SOURCE_NAME))) BRANCH_NAME=snapshot else BRANCH_NAME=$(LLVM_VERSION) endif VENDOR=$(shell lsb_release -is) DISTRO=$(shell lsb_release -sc) DERIVATIVE := $(shell if dpkg-vendor --derives-from Ubuntu; then echo Ubuntu; \ elif dpkg-vendor --derives-from Debian; then echo Debian; \ else echo Unknown; fi) SONAME_EXT := 1 SONAME_OPENMP := 5 # Manage the case when the version is 3.5~svn213052-1~exp1 or 3.4.2-1 DEBIAN_REVISION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: 1:([0-9.]+)(~|-)(.*),\3,p") ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) NCPUS := $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) else NCPUS := $(shell nproc) endif # set this macro to anything else than "yes" to avoid generating alternative # build dependencies on hello in the control file. BD_ALT_HELLO = yes ifeq ($(BD_ALT_HELLO),yes) BD_ALT_HELLO_SUBST = 's/@BEGIN_OPTIONAL_HELLO@//g;s/@END_OPTIONAL_HELLO@//g' else BD_ALT_HELLO_SUBST = '/@BEGIN_OPTIONAL_HELLO@/,/@END_OPTIONAL_HELLO@/d' endif # this contains all packages to be built. Note that for at least the clean target, # this always includes the binary-indep packages. packages := $(shell dh_listpackages) # no 32bit support FLANG_ARCHS := amd64 arm64 ppc64el ppc64 sparc64 riscv64 loong64 # flang has some memory hogs, of up to 6.2gb per process. Limit the parallel jobs # based on the available memory ifneq (,$(filter $(DEB_HOST_ARCH), $(FLANG_ARCHS))) MEM_PER_CPU=6000 else MEM_PER_CPU=2100 endif NJOBS := $(shell mt=`awk '/^(MemAvail|SwapFree)/ { mt += $$2 } END {print mt}' /proc/meminfo`; \ awk -vn=$(NCPUS) -vmt=$$mt -vm=$(MEM_PER_CPU) \ 'END { mt/=1024; n2 = int(mt/m); print n==1 || n2<=1 ? 1 : n2<=n ? n2 : n }' < /dev/null) TIME_COMMAND = $(CURDIR)/debian/usage-wrapper.py $(SUMMARY_ONLY) -j $(NJOBS) --base-memory -m 4.0 -o usage-$(notdir $@)-$(DEB_HOST_ARCH).svg TIME_BIN := $(if $(wildcard /usr/bin/time),/usr/bin/time,/bin/time) TIME_COMMAND = $(TIME_BIN) -v USAGE_BUILD_DEP = $(EMPTY) time, ifneq (,$(findstring usage-wrapper, $(TIME_COMMAND))) ifeq ($(DERIVATIVE),Ubuntu) USAGE_BUILD_DEP = $(EMPTY) python3:any, python3-psutil, python3-matplotlib [!i386], ifeq ($(DEB_HOST_ARCH),i386) SUMMARY_ONLY = --summary-only endif else USAGE_BUILD_DEP = $(EMPTY) python3:any, python3-psutil [!hurd-i386 !hurd-amd64], python3-matplotlib [!m68k !sh4 !x32 !hurd-i386 !hurd-amd64], ifneq (,$(filter $(DEB_HOST_ARCH), hurd-i386 hurd-amd64)) TIME_COMMAND = $(TIME_BIN) -v endif ifneq (,$(filter $(DEB_HOST_ARCH), m68k sh4 x32)) SUMMARY_ONLY = --summary-only endif endif endif DH_VERSION := $(shell dpkg -s debhelper | grep '^Version' | awk '{print $$2}') include /usr/share/dpkg/architecture.mk MULTILIB_ARCHS := amd64 i386 mips64 mips64el mipsel powerpc ppc64 s390x sparc sparc64 x32 ifeq ($(DERIVATIVE),Ubuntu) ifeq (,$(filter $(DISTRO), bionic focal jammy noble)) MULTILIB_ARCHS := $(filter-out s390x, $(MULTILIB_ARCHS)) endif endif CONFIGURE_EXTRA = # these are handled on a per stage / build basis ifeq ($(VENDOR)-$(DEB_HOST_ARCH),Ubuntu-ppc64el) export DEB_CFLAGS_MAINT_STRIP = -g -O3 export DEB_CXXFLAGS_MAINT_STRIP = -g -O3 else export DEB_CFLAGS_MAINT_STRIP = -g -O2 export DEB_CXXFLAGS_MAINT_STRIP = -g -O2 endif include /usr/share/dpkg/buildflags.mk # We use a stage2 build. It means that a first clang is built using gcc, # a second clang is built with the first # And the various components are built using the second clang. # See https://llvm.org/docs/AdvancedBuilds.html # collect additional flags for all stages all builds CFLAGS_EXTRA = -Wno-unused-command-line-argument CXXFLAGS_EXTRA = -Wno-unused-command-line-argument LDFLAGS_EXTRA = -Wl,--build-id # collect all flags for stage 1 toolchain build only STAGE_1_CFLAGS = $(CFLAGS) $(CFLAGS_EXTRA) $(CPPFLAGS) STAGE_1_CXXFLAGS = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(CPPFLAGS) STAGE_1_LDFLAGS = $(LDFLAGS) $(LDFLAGS_EXTRA) # If we build with libc++, we might want to set different arguments for # stage 1 & runtimes RUNTIMES_CFLAGS = $(STAGE_1_CFLAGS) RUNTIMES_CXXFLAGS := $(STAGE_1_CXXFLAGS) RUNTIMES_LDFLAGS := $(STAGE_1_LDFLAGS) # collect all flags for stage 2 toolchain and stand-alone builds STAGE_2_CFLAGS = $(CFLAGS) $(CFLAGS_EXTRA) $(CPPFLAGS) STAGE_2_CXXFLAGS = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(CPPFLAGS) STAGE_2_LDFLAGS = $(LDFLAGS) $(LDFLAGS_EXTRA) # collect additional cmake options for toolchain build configuration STAGE_1_CMAKE_EXTRA = STAGE_2_CMAKE_EXTRA = STAGE_ALL_CMAKE_EXTRA = # toolchain config-only var combining all stage 1 cmake options CMAKE_EXTRA = $(STAGE_1_CMAKE_EXTRA) $(STAGE_ALL_CMAKE_EXTRA) # toolchain config-only var prepending BOOTSTRAP_ to all stage 2 cmake options BOOTSTRAP_CMAKE_EXTRA = $(foreach extra,$(STAGE_2_CMAKE_EXTRA) $(STAGE_ALL_CMAKE_EXTRA), $(subst -D,-DBOOTSTRAP_,$(extra))) BASE_PATH := $(CURDIR) STAGE_1_BIN_DIR := $(BASE_PATH)/$(TARGET_BUILD)/bin STAGE_1_LIB_DIR := $(BASE_PATH)/$(TARGET_BUILD)/lib STAGE_2_BIN_DIR := $(BASE_PATH)/$(TARGET_BUILD_STAGE2)/bin STAGE_2_LIB_DIR := $(BASE_PATH)/$(TARGET_BUILD_STAGE2)/lib # toggleable defaults COMPILER_RT_USE_BUILTINS_LIBRARY := ON LIBCXX_EXCEPTIONS := ON LIBCXX_USE_COMPILER_RT := ON # We want to set the clang extra version ONLY in stage 2 # because we want the clang stage 1 to be as reproducible as possible # when building with sccache (because this tool do a hash using the # compiler binary and other things) STAGE_2_CMAKE_EXTRA += -DCLANG_REPOSITORY_STRING=$(DEBIAN_REVISION) ifneq (,$(filter $(DEB_HOST_ARCH),sparc sparc64)) STAGE_1_CMAKE_EXTRA += -DLLVM_PARALLEL_LINK_JOBS=4 endif ifneq (,$(filter $(DEB_HOST_ARCH),i386 hurd-i386 armel mipsel mips64el powerpc riscv64)) # For some reason, in the stage2 build, when clang is used to compile # itself. The atomic detection is failing on armel and riscv64. Forcing the inclusion # everywhere and in all stages LDFLAGS_EXTRA += -latomic endif Z3_FLAG = -DLLVM_ENABLE_Z3_SOLVER=OFF # no ocaml support in main for Ubuntu ifneq ($(DERIVATIVE),Ubuntu) ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' libz3-dev) gt 4.7.0; echo $$?),0) ifeq (,$(filter $(DEB_HOST_ARCH),sh4)) Z3_FLAG = -DLLVM_ENABLE_Z3_SOLVER=ON endif endif endif STAGE_2_CMAKE_EXTRA += $(Z3_FLAG) ifneq (,$(findstring =ON, $(Z3_FLAG))) Z3_DEV_DEP = libz3-dev [!sh4], endif # Change the default CPU for s390x ZARCH=z196 ifeq ($(DERIVATIVE),Ubuntu) ZARCH=z13 endif STAGE_2_CMAKE_EXTRA += -DCLANG_SYSTEMZ_DEFAULT_ARCH=$(ZARCH) # clangd remote index support requires GRPC & protobuf. # Enable if minimum tested versions are available. CLANGD_GRPC_INSTALLED=no ifeq (,$(filter stage1, $(DEB_BUILD_PROFILES))) ifeq ($(shell v=$$(dpkg-query -W -f '$${Version}' libgrpc++-dev 2>/dev/null); if [ -z "$$v" ]; then echo 1; else dpkg --compare-versions $$v gt 1.30.0; echo $$?; fi),0) ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' protobuf-compiler-grpc) gt 1.30.0; echo $$?),0) ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' libprotobuf-dev) gt 3.12.0; echo $$?),0) ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' protobuf-compiler) gt 3.12.0; echo $$?),0) CLANGD_GRPC_INSTALLED=yes STAGE_2_CMAKE_EXTRA += -DCLANGD_ENABLE_REMOTE=ON endif endif endif endif endif export CC=gcc-$(GCC_VERSION) export CXX=g++-$(GCC_VERSION) ifneq (,$(findstring $(DEB_HOST_ARCH),armel)) STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=arm-linux-gnueabi # align arch profile with debian baseline # https://wiki.debian.org/ArmEabiPort CFLAGS_EXTRA += -march=armv5t CXXFLAGS_EXTRA += -march=armv5t # disable compiler-rt builtins (not supported for baseline armel arch: armv5t) # See http://lists.llvm.org/pipermail/llvm-dev/2016-May/099761.html STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_BUILD_BUILTINS=OFF COMPILER_RT_USE_BUILTINS_LIBRARY := OFF LIBCXX_USE_COMPILER_RT := OFF # disable scudo standalone (not supported for baseline armel arch: armv5t) STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_BUILD_SCUDO_STANDALONE=OFF endif ifneq (,$(findstring $(DEB_HOST_ARCH),armhf)) STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=arm-linux-gnueabihf # align arch profile with debian baseline # https://wiki.debian.org/ArmHardFloatPort#Minimum_CPU_.26_FPU CFLAGS_EXTRA += -march=armv7-a -mfpu=vfpv3-d16 CXXFLAGS_EXTRA += -march=armv7-a -mfpu=vfpv3-d16 endif ifneq (,$(filter $(DEB_HOST_ARCH),i386)) # Sometimes, i386 needs help with the triple STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=i386-linux-gnu CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=i386-linux-gnu endif ifneq (,$(filter $(DEB_HOST_ARCH),mips64el)) # avoid an issue with search path on mips64el # https://bugs.llvm.org/show_bug.cgi?id=41204 STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=mips64el-linux-gnuabi64 CFLAGS_EXTRA += -mxgot CXXFLAGS_EXTRA += -mxgot LDFLAGS_EXTRA += -mxgot endif ifneq (,$(filter $(DEB_HOST_ARCH),powerpc)) STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=powerpc-linux-gnu endif # debug symbols OOM in Ubuntu Ubuntu and slows down build process. ifneq (,$(filter $(DEB_HOST_ARCH),riscv64)) opt_flags = -O2 -DNDEBUG -g0 else opt_flags = -O2 -DNDEBUG -g1 endif ifneq (,$(filter $(DEB_HOST_ARCH),sparc)) STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=sparc-linux-gnu STAGE_ALL_CMAKE_EXTRA += -DLLVM_PARALLEL_LINK_JOBS=4 endif ifneq (,$(filter $(DEB_HOST_ARCH),sparc64)) STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=sparc64-linux-gnu STAGE_ALL_CMAKE_EXTRA += -DLLVM_PARALLEL_LINK_JOBS=4 endif ifneq (,$(filter $(DEB_HOST_ARCH),s390x)) STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=s390x-linux-gnu LIBCXX_EXCEPTIONS := OFF # disable compiler-rt builtins (not supported for s390x) STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_BUILD_BUILTINS=OFF COMPILER_RT_USE_BUILTINS_LIBRARY := OFF LIBCXX_USE_COMPILER_RT := OFF endif ifneq (,$(filter $(DEB_HOST_ARCH),mips64el)) STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_BUILD_BUILTINS=OFF COMPILER_RT_USE_BUILTINS_LIBRARY := OFF LIBCXX_USE_COMPILER_RT := OFF endif ifneq (,$(filter $(DEB_HOST_ARCH),x32)) STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=x86_64-linux-gnux32 STAGE_ALL_CMAKE_EXTRA += -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnux32 STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_BUILD_BUILTINS=OFF COMPILER_RT_USE_BUILTINS_LIBRARY := OFF LIBCXX_USE_COMPILER_RT := OFF endif ifneq (,$(filter $(DEB_HOST_ARCH),hurd-i386)) endif ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' g++-$(GCC_VERSION)) ge 4.8-20121128-1~ ; echo $$?),0) control_vars = '-Vdep:devlibs=libstdc++-$(GCC_VERSION)-dev, libgcc-$(GCC_VERSION)-dev' \ '-Vdep:devlibs-objc=libobjc-$(GCC_VERSION)-dev' else ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' g++-$(GCC_VERSION)) ge 4.7.2-10~ ; echo $$?),0) control_vars = '-Vdep:devlibs=libstdc++6-$(GCC_VERSION)-dev, libgcc-$(GCC_VERSION)-dev' \ '-Vdep:devlibs-objc=libobjc-$(GCC_VERSION)-dev' else control_vars = '-Vdep:devlibs=libstdc++6-$(GCC_VERSION)-dev' endif ifneq (,$(filter stage1, $(DEB_BUILD_PROFILES))) LLVM_SPIRV_INSTALLED = no else LLVM_SPIRV_VERSION := $(LLVM_VERSION) LLVM_SPIRV := $(shell bash -c "command -v llvm-spirv-$(LLVM_SPIRV_VERSION)" 2>/dev/null) ifndef LLVM_SPIRV LLVM_SPIRV_VERSION := $(shell expr $(LLVM_VERSION) - 1) LLVM_SPIRV := $(shell bash -c "command -v llvm-spirv-$(LLVM_SPIRV_VERSION)" 2>/dev/null) endif # Disable spirv support for most of the distro versions # It needs llvm-spirv-17 and it is rarely available # Be prescritive SPIRV_DISABLE_DISTRO := bionic buster lunar jammy focal buster bullseye bookworm ifndef LLVM_SPIRV LLVM_SPIRV_INSTALLED = no else ifeq (,$(filter-out $(SPIRV_DISABLE_DISTRO), $(DISTRO))) # Too old llvm-spirv version are failing. See #52200 LLVM_SPIRV_INSTALLED = no else LLVM_SPIRV_INSTALLED = yes endif endif endif LIBCLC_TARGETS_TO_BUILD=amdgcn--;amdgcn--amdhsa;amdgcn-mesa-mesa3d;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl LIBCLC_LLVM_SPIRV = ifeq ($(LLVM_SPIRV_INSTALLED),yes) LIBCLC_TARGETS_TO_BUILD := $(LIBCLC_TARGETS_TO_BUILD);spirv-mesa3d-;spirv64-mesa3d- LIBCLC_LLVM_SPIRV = -DLLVM_SPIRV=$(LLVM_SPIRV) endif BINUTILS_GOLD_ARCHS := amd64 arm64 armhf i386 ppc64 ppc64el x32 s390x hurd-i386 hurd-amd64 ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' binutils) ge 2.23.1-1~exp3 ; echo $$?),0) ifneq (,$(filter $(DEB_HOST_ARCH),$(BINUTILS_GOLD_ARCHS))) STAGE_ALL_CMAKE_EXTRA += -DLLVM_USE_LINKER=gold STAGE_ALL_CMAKE_EXTRA += -DLLVM_BINUTILS_INCDIR=/usr/include/ endif endif ifneq (,$(filter bolt-$(LLVM_VERSION), $(packages))) PROJECTS += ;bolt endif ifneq (,$(filter libllvmlibc-$(LLVM_VERSION)-dev, $(packages))) LLVM_LIBC_ENABLE=yes LLVM_LIBC_DISABLE_DISTRO := bionic ifeq (,$(filter $(DISTRO), $(LLVM_LIBC_DISABLE_DISTRO))) RUNTIMES += ;libc else LLVM_LIBC_ENABLE=no endif endif ifneq ($(LLVM_LIBC_ENABLE),no) $(info LLVM libc disabled for $(DISTRO)) endif ifneq (,$(filter $(DEB_HOST_ARCH), $(FLANG_ARCHS))) PROJECTS += ;flang endif CODECOVERAGE=no ifneq (,$(filter codecoverage,$(DEB_BUILD_OPTIONS))) # enable the code coverage CODECOVERAGE=yes # for -fvisibility-inlines-hidden see http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130729/183016.html CXXFLAGS_EXTRA += -fprofile-arcs -ftest-coverage LDFLAGS_EXTRA += -coverage -lgcov RUN_TEST=yes # OpenMP doesn't respect LDFLAGS STAGE_2_CMAKE_EXTRA+= -DLIBOMP_LDFLAGS="-coverage -lgcov" # don't pass LDFLAGS_EXTRA because it expects gcc arg endif # Enable polly (or not) POLLY_ENABLE=yes ifneq (,$(filter $(DEB_HOST_ARCH), powerpc)) POLLY_ENABLE=no else PROJECTS+=;polly endif # Enable libunwind (or not) LIBUNWIND_ENABLE=yes ifneq (,$(filter $(DEB_HOST_ARCH), s390x armel m68k mipsel mips64el hurd-i386 hurd-amd64 powerpc sparc sparc64 x32)) LIBUNWIND_ENABLE=no # do not use compiler-rt builtins for libcxx (libcxxabi) when libunwind is # disabled since the gnu implementation in libgcc_s will then be required LIBCXX_USE_COMPILER_RT := OFF # See https://github.com/llvm/llvm-project/issues/77846 STAGE_ALL_CMAKE_EXTRA += -DLIBCXXABI_USE_LLVM_UNWINDER=OFF else RUNTIMES += ;libunwind STAGE_ALL_CMAKE_EXTRA += -DLIBCXXABI_USE_LLVM_UNWINDER=ON endif # Enable openmp (or not) OMP_OFFLOAD_ARCHS = amd64 arm64 armhf ppc64 ppc64el hurd-amd64 OMP_ARCHS = $(OMP_OFFLOAD_ARCHS) loong64 mips64el riscv64 OPENMP_ENABLE=yes ifeq (,$(filter $(DEB_HOST_ARCH), $(OMP_ARCHS))) OPENMP_ENABLE=no else RUNTIMES += ;openmp ifneq (,$(filter $(DEB_HOST_ARCH), $(OMP_OFFLOAD_ARCHS))) RUNTIMES += ;offload endif STAGE_ALL_CMAKE_EXTRA += -DLIBOMP_LIBFLAGS="-lm" ifeq ($(LIBUNWIND_ENABLE),yes) STAGE_ALL_CMAKE_EXTRA += -DOPENMP_USE_LLVM_UNWINDER=ON endif endif # Do not install objects STAGE_ALL_CMAKE_EXTRA += -DMLIR_INSTALL_AGGREGATE_OBJECTS=OFF RUN_TEST=yes ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) RUN_TEST=no endif ifeq ($(DERIVATIVE),Ubuntu) ifeq (riscv64,$(DEB_HOST_ARCH)) RUN_TEST=no endif endif # llvm tests timeout, disable it on mipsel and x32 ifneq (,$(filter $(DEB_HOST_ARCH), mipsel mips64el x32)) RUN_TEST=no endif SCAN_BUILD=no ifneq (,$(filter scan-build,$(DEB_BUILD_OPTIONS))) # enable the build using scan-build # The package are installed through the variable declarations: # OTHERMIRROR="deb http://llvm.org/apt/unstable/ llvm-toolchain main" # EXTRAPACKAGES="clang-X" SCAN_BUILD=yes PRE_PROCESS=scan-build-$(LLVM_VERSION) --show-description -analyzer-config stable-report-filename=true PRE_PROCESS_CONF=scan-build-$(LLVM_VERSION) # no need to run tests in this case RUN_TEST=no CONFIGURE_EXTRA += --enable-assertions STAGE_ALL_CMAKE_EXTRA += -DLLVM_ENABLE_ASSERTIONS=ON endif ifneq (,$(filter coverity,$(DEB_BUILD_OPTIONS))) # enable the build using coverity # pbuilder contains BINDMOUNTS="/opt/cov-analysis/" # And we have some pbuilder hooks to configure and pack the result # Where the binaries are installed on the jenkins instance PRE_PROCESS=PATH=$$PATH:/opt/cov-analysis/bin/ cov-build --dir cov-int # We don't want to check the temporary files produced by the configure PRE_PROCESS_CONF= COVERITY_ENABLE=1 CONFIGURE_EXTRA += --enable-assertions STAGE_ALL_CMAKE_EXTRA += -DLLVM_ENABLE_ASSERTIONS=ON # no need to run tests in this case RUN_TEST=no else COVERITY_ENABLE=0 endif LLDB_ENABLE=no # hurd has threading issues LLDB_ARCHS := amd64 arm64 armel armhf i386 loong64 m68k ppc64el riscv64 s390x x32 ifneq (,$(filter $(DEB_HOST_ARCH),$(LLDB_ARCHS))) STAGE_ALL_CMAKE_EXTRA += -DLLDB_ENABLE_LUA=OFF PROJECTS+=;lldb endif ifneq (,$(filter $(DEB_HOST_ARCH),i386 amd64)) INTEL_PT_DISABLE_DISTRO := bionic # Disable intel-pt on old distro, fails on bionic (too old) ifeq (,$(filter $(DISTRO), $(INTEL_PT_DISABLE_DISTRO))) STAGE_ALL_CMAKE_EXTRA += -DLLDB_BUILD_INTEL_PT=ON -DLIBIPT_INCLUDE_PATH=/usr/include -DLIBIPT_LIBRARY_PATH=/usr/lib/$(DEB_HOST_MULTIARCH) endif endif LLDB_PYTHON_DISABLE_DISTRO := bionic buster LLDB_PYTHON_ENABLE=yes # Disable zstd on old distro, fails on lld ifeq (,$(filter-out $(LLDB_PYTHON_DISABLE_DISTRO), $(DISTRO))) # Don't enable lld python for old distros STAGE_ALL_CMAKE_EXTRA += -DLLDB_ENABLE_PYTHON=OFF LLDB_PYTHON_ENABLE=no $(info LLBD Python disabled for $(DISTRO)) endif LIBCXX_WASM_ENABLE=yes LIBCXX_WASM_DISABLE_DISTRO := bionic buster focal bullseye jammy # Either wasi-libc doesn't exist / too old # or we have this bug # https://sourceware.org/bugzilla/show_bug.cgi?id=27558 ifeq (,$(filter-out $(LIBCXX_WASM_DISABLE_DISTRO), $(DISTRO))) LIBCXX_WASM_ENABLE=no $(info libcxx wasm disabled for $(DISTRO)) endif DOC_GENERATION=yes DOC_GENERATION_DISTRO := buster bullseye bionic focal # LLVM upstream moved to myst_parser but it isn't available on old distro ifeq (,$(filter-out $(DOC_GENERATION_DISTRO), $(DISTRO))) DOC_GENERATION=no $(info Doc generation disabled for $(DISTRO)) endif ifneq (,$(filter $(DEB_HOST_ARCH),powerpc)) LIBCXX_WASM_ENABLE=no endif LLD_ENABLE=yes ifneq (,$(filter $(DEB_HOST_ARCH_OS),linux)) # only for linux STAGE_2_CMAKE_EXTRA += -DLLVM_USE_PERF=ON -DLLVM_ENABLE_LIBPFM=ON endif LLVM_ENABLE_ZSTD_DISABLE_DISTRO := bionic buster # Disable zstd on old distro, fails on lld ifeq (,$(filter-out $(LLVM_ENABLE_ZSTD_DISABLE_DISTRO), $(DISTRO))) STAGE_ALL_CMAKE_EXTRA += -DLLVM_ENABLE_ZSTD=OFF endif LTO_ENABLE=no # Only enable it for archs supporting gold ifneq (,$(filter $(DEB_HOST_ARCH),$(BINUTILS_GOLD_ARCHS))) # LTO requires a bunch of memory. Don't do it everywhere LTO_DISABLE_ARCHS := i386 armhf s390x ppc64 x32 ifeq (,$(filter-out $(LTO_DISABLE_ARCHS), $(DEB_HOST_ARCH))) LTO_ENABLE=no else # Disable for now because of # https://github.com/llvm/llvm-project/issues/58317#issuecomment-1276190743 # LTO_ENABLE=yes # STAGE_2_CMAKE_EXTRA += -DLLVM_ENABLE_LTO="On" endif endif ifneq ($(LTO_ENABLE),no) $(info LTO disabled for $(DEB_HOST_ARCH)) endif # https://bugs.launchpad.net/bugs/2016471 ifeq (,$(filter-out $(LTO_DISABLE_ARCHS), $(DEB_HOST_ARCH))) LD_GOLD_SUPPORTS_NO_SYMBOLIC := $(shell ld.gold --help | grep -q -w '-Bno-symbolic' && echo "yes" || echo "no") ifeq ($(LD_GOLD_SUPPORTS_NO_SYMBOLIC),yes) STAGE_2_CMAKE_EXTRA += -DLIBOMP_LDFLAGS=-Wl,-Bno-symbolic endif endif DH_OPTIONS= OCAML_ENABLE= no OCAML_ARCHS := amd64 arm64 ppc64el riscv64 s390x ifneq (,$(filter $(DEB_HOST_ARCH),$(OCAML_ARCHS))) # Enable OCAML for this arch. OCAML_ENABLE=yes OCAML_STDLIB_DIR ?= $(shell ocamlc -where) DH_OPTIONS=--with ocaml endif LIBFUZZER_ENABLE=yes ifeq (,$(filter $(DEB_HOST_ARCH_OS),linux)) LIBFUZZER_ENABLE=no $(info Libfuzzer disabled for $(DEB_HOST_ARCH_OS)) endif ifneq (,$(filter $(DEB_HOST_ARCH), mipsel)) LIBOMP_ARCH = mips endif ifneq (,$(filter $(DEB_HOST_ARCH), mips64 mips64el)) LIBOMP_ARCH = mips64 endif # if cmake is installed in /tmp/cmake/ uses it # Used to build llvm on old ubuntu (precise) on the llvm.org/apt/ ci CMAKE_BIN=cmake ifeq ($(shell test -e /tmp/cmake/bin/cmake && echo -n yes),yes) CMAKE_BIN=/tmp/cmake/bin/cmake export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:/tmp/cmake/bin/ endif SCCACHE_ENABLE=no SCCACHE_CMAKE = # if sccache is installed in the chroot, use it ifeq ($(shell test -e /opt/sccache/sccache && echo -n yes),yes) ifneq (,$(filter $(DEB_HOST_ARCH),i386 amd64 s390x)) STAGE_1_CMAKE_EXTRA += $(SCCACHE_CMAKE) SCCACHE_ENABLE=yes SCCACHE_PATH=/opt/sccache/ SCCACHE_CMD=$(SCCACHE_PATH)/sccache SCCACHE_CMAKE = -DCMAKE_C_COMPILER_LAUNCHER=$(SCCACHE_CMD) -DCMAKE_CXX_COMPILER_LAUNCHER=$(SCCACHE_CMD) export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:/opt/sccache endif endif COVERITY_ENABLE=0 ifneq (,$(filter coverity,$(DEB_BUILD_OPTIONS))) # enable the build using coverity # pbuilder contains BINDMOUNTS="/opt/cov-analysis/" # And we have some pbuilder hooks to configure and pack the result # Where the binaries are installed on the jenkins instance PRE_PROCESS=PATH=$$PATH:/opt/cov-analysis/bin/ cov-build --dir cov-int # We don't want to check the temporary files produced by the configure PRE_PROCESS_CONF= COVERITY_ENABLE=1 CONFIGURE_EXTRA += --enable-assertions STAGE_ALL_CMAKE_EXTRA += -DLLVM_ENABLE_ASSERTIONS=ON SCCACHE_ENABLE=no SCCACHE_CMAKE= # no need to run tests in this case RUN_TEST=no endif # enables cmake build targets like stage2-[target_name] ENABLED_STAGE2_CMAKE_BUILD_TARGETS = check-all;check-llvm;check-clang;check-clang-tools;check-lld;check-libcxx;check-libcxxabi;check-mlir;check-libc;check-sanitizer;llvm-config;test-suite %: dh $@ $(DH_OPTIONS) # For some reasons, some spaces are added, removing them PROJECTS_LIST := $(shell echo "$(PROJECTS)"|sed -e "s| ||g") RUNTIMES_LIST := $(shell echo "$(RUNTIMES)"|sed -e "s| ||g") stamps/preconfigure: if ! grep -qs '/proc ' /proc/mounts; then \ echo "/proc needs to be mounted"; \ exit 1; \ fi if test "$(DISTRO)" = "bookworm" -a "$(LLVM_SPIRV_INSTALLED)" = "no"; then \ echo "llvm spriv isn't detected while it should probably for this distro"; \ fi @echo "Memory:" @if [ -e /proc/meminfo ]; then \ cat /proc/meminfo | grep -E '(Mem|Swap)Free|Cached'; \ else \ echo " No memory info available"; \ fi @echo "Processors: $$(cat /proc/cpuinfo | grep --count '^processor')" @echo "Used Processors: $(NJOBS) (out of $(NCPUS)), $(MEM_PER_CPU)kb/processor" @echo "DEB_BUILD_OPTIONS=$(DEB_BUILD_OPTIONS)" @echo "DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH)" @echo "DEB_HOST_GNU_TYPE=$(DEB_HOST_GNU_TYPE)" @echo "DEB_HOST_ARCH_BITS=$(DEB_HOST_ARCH_BITS)" @echo "DEB_HOST_ARCH=$(DEB_HOST_ARCH)" @echo "DEB_HOST_ARCH_OS=$(DEB_HOST_ARCH_OS)" @echo "DEB_BUILD_MAINT_OPTIONS=$(DEB_BUILD_MAINT_OPTIONS)" @echo "DISTRO=$(DISTRO)" @echo "GCC_VERSION=$(GCC_VERSION)" @echo "PROJECTS=$(PROJECTS_LIST)" @echo "RUNTIMES=$(RUNTIMES_LIST)" @echo "LLVM_VERSION=$(LLVM_VERSION)" @echo "LLVM_VERSION_MINOR=$(LLVM_VERSION_MINOR)" @echo "LLVM_VERSION_FULL=$(LLVM_VERSION_FULL)" @echo "LLVM_VERSION_SNAPSHOT=$(LLVM_VERSION_SNAPSHOT)" @echo "PATH=$(PATH)" @echo "LD_LIBRARY_PATH=$$LD_LIBRARY_PATH" @echo "RUNTIMES_CXXFLAGS=$(RUNTIMES_CXXFLAGS)" @echo "STAGE_1_CXXFLAGS=$(STAGE_1_CXXFLAGS)" @echo "STAGE_2_CFLAGS=$(STAGE_2_CFLAGS)" @echo "LIBFUZZER_ENABLE=$(LIBFUZZER_ENABLE)" @echo "LTO_ENABLE=$(LTO_ENABLE)" @echo "COMPILER_RT_WASM_ENABLE=$(COMPILER_RT_WASM_ENABLE)" @echo "LIBCXX_WASM_ENABLE=$(LIBCXX_WASM_ENABLE)" @echo "SCCACHE_ENABLE=$(SCCACHE_ENABLE)" @echo "LLVM_SPIRV=$(LLVM_SPIRV)" @echo "LLVM_SPIRV_INSTALLED=$(LLVM_SPIRV_INSTALLED)" @echo "DOC_GENERATION=$(DOC_GENERATION)" for f in debian/*.in debian/tests/*.in; do \ f2=$$(echo $$f | sed 's/\.in$$//;s/X\.Y/$(LLVM_VERSION)/'); \ echo "$$f => $$f2"; \ sed -e 's|@DEB_HOST_MULTIARCH@|$(DEB_HOST_MULTIARCH)|g' \ -e "s|@USAGE_BUILD_DEP@|$(USAGE_BUILD_DEP)|g" \ -e "s|@Z3_DEV_DEP@|$(Z3_DEV_DEP)|g" \ -e "s|@MULTILIB_ARCHS@|$(MULTILIB_ARCHS)|g" \ -e "s|@LLDB_ARCHS@|$(LLDB_ARCHS)|g" \ -e "s|@OCAML_ARCHS@|$(OCAML_ARCHS)|g" \ -e "s|@OMP_ARCHS@|$(OMP_ARCHS)|g" \ -e "s|@FLANG_ARCHS@|$(FLANG_ARCHS)|g" \ -e "s|@BRANCH_NAME@|$(BRANCH_NAME)|g" \ -e "s|@OCAML_STDLIB_DIR@|$(OCAML_STDLIB_DIR)|g" \ -e "s|@LLVM_EPOCH@|$(LLVM_EPOCH)|g" \ -e "s|@LLVM_VERSION_FULL@|$(LLVM_VERSION_FULL)|g" \ -e "s|@LLVM_VERSION_MINOR@|$(LLVM_VERSION_MINOR)|g" \ -e "s|@LLVM_VERSION_NEXT@|$(LLVM_VERSION_NEXT)|g" \ -e "s|@LLVM_VERSION@|$(LLVM_VERSION)|g" \ -e $(BD_ALT_HELLO_SUBST) \ $$f > $$f2; \ [ -x $$f ] && chmod +x $$f2; \ done # Make install file executable for dh-exec chmod +x \ debian/clang-tools-$(LLVM_VERSION).install \ debian/libclang-$(LLVM_VERSION)-dev.install \ debian/libclang-rt-$(LLVM_VERSION)-dev.install \ debian/libpolly-$(LLVM_VERSION)-dev.install \ debian/libomp-$(LLVM_VERSION)-dev.install \ debian/libomp5-$(LLVM_VERSION).install \ debian/llvm-$(LLVM_VERSION)-dev.install \ debian/llvm-$(LLVM_VERSION)-linker-tools.install \ debian/llvm-$(LLVM_VERSION)-linker-tools.links \ debian/libbolt-$(LLVM_VERSION)-dev.install # workaround the breaks/replaces/conflicts introduced with the libc++ move # we update the version to make it work with apt.llvm.org # Yeah, this is ugly but I don't know how to do better if test "$(LLVM_VERSION)" = "19"; then \ if echo $(LLVM_VERSION_SNAPSHOT)| grep -q "~++"; then \ sed -i -e "s|(<< 1:19.1.0~++rc3-1~exp2)|(<< 1:19.1.0~++20240910033111)|g" debian/control; \ sed -i -e "s|(<< 1:19.1.0~++rc4-5)|(<< 1:19.1.0~++20240917071600)|g" debian/control; \ sed -i -e "s|(<< 1:19.1.0-4)|(<< 1:19.1.0~++20240917071600)|g" debian/control; \ fi; \ fi # llvm-spirv was found, so we can enable *.spv files. Debian # buster and Ubuntu 18.04 don't have llvm-spirv to create the # *.spv files. if test "$(LLVM_SPIRV_INSTALLED)" = "yes"; then \ sed -i -e "s|#spv\ ||g" debian/libclc-$(LLVM_VERSION).install; \ fi # disable libc++-X.Y-dev-wasm32.install.in on old distro if test "$(LIBCXX_WASM_ENABLE)" = "no"; then \ echo "" > debian/libc++-$(LLVM_VERSION)-dev-wasm32.install; \ echo "" > debian/libc++abi-$(LLVM_VERSION)-dev-wasm32.install; \ else \ if ! dpkg -l|grep -q wasi-libc; then \ echo "Could not find wasi-libc on the system"; \ echo "Please check that the package is available on the system"; \ echo "it might be that the 'hello' package is installed by another constraint"; \ exit 1; \ fi; \ fi if test "$(LLVM_LIBC_ENABLE)" = "no"; then \ echo "" > debian/libllvmlibc-$(LLVM_VERSION)-dev.install; \ fi # Conditionally enable install clangd grpc files if test "$(CLANGD_GRPC_INSTALLED)" = "yes"; then \ sed -i -e "s|#grpc\ ||g" debian/libclang-$(LLVM_VERSION)-dev.install; \ fi if ! dh_listpackages|grep -q clang-$(LLVM_VERSION); then \ echo "Could not find clang-$(LLVM_VERSION) in the list of packages"; \ echo "Refresh debian/control ?"; \ echo "Package list:"; \ dh_listpackages; \ exit 1; \ fi @mkdir -p stamps touch $@ # Override this two targets. They are trying to manage the .in conversion for me override_dh_ocamlinit: override_dh_ocamlclean: override_dh_auto_configure: stamps/configure stamps/configure: stamps/preconfigure ifeq (${SCCACHE_ENABLE},yes) ls -al $(SCCACHE_PATH)* endif echo "Using gcc: " $(CC) -v $(CXX) -v mkdir -p $(TARGET_BUILD) # remove in case of artifact rm -rf build if test "$(SCAN_BUILD)" = "yes"; then \ patch -f -p1 < debian/patches/on-the-fly/use-scan-build-runtimes.diff||true; \ fi # Configure coverity (we need the compilers) + work around perf issues -(if test $(COVERITY_ENABLE) -eq 1; then \ export PATH=$$PATH:/opt/cov-analysis/bin/; \ cov-configure --compiler clang --comptype clang; \ cov-configure --compiler gcc-$(GCC_VERSION) --comptype gcc; \ cov-configure --compiler g++-$(GCC_VERSION) --comptype gcc; \ cov-configure -co /usr/bin/g++-$(GCC_VERSION) --comptype gcc -- -fPIC -std=c++11; \ cov-configure -co /usr/bin/gcc-$(GCC_VERSION) --comptype gcc -- -fPIC; \ cov-configure -co /usr/bin/g++-$(GCC_VERSION) --comptype gcc -- -fPIC -std=c++11 -fno-exceptions; \ cov-configure -co /usr/bin/g++-$(GCC_VERSION) --comptype gcc --template \ --xml-option append_arg:"--ppp_translator" \ --xml-option append_arg:"replace/llvm::AlignOf::Alignment/(llvm::AlignOf::Alignment)" \ --xml-option append_arg:"--ppp_translator" \ --xml-option append_arg:"replace/llvm::AlignOf::Alignment/(llvm::AlignOf::Alignment)"; \ cov-configure --compiler c++ --comptype g++ --template \ --xml-option append_arg:"--ppp_translator" \ --xml-option append_arg:"replace/llvm::AlignOf::Alignment/(llvm::AlignOf::Alignment)" \ --xml-option append_arg:"--ppp_translator" \ --xml-option append_arg:"replace/llvm::AlignOf::Alignment/(llvm::AlignOf::Alignment)"; \ fi) # Fails with No target "unwind_static" # -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON \ # -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY=OFF \ # -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=ON \ #- to libc++ when libunwind is built #- Matches what is done on brew: #- https://bit.ly/3kDNpC9 ifeq (${SCCACHE_ENABLE},yes) # Just in case... $(SCCACHE_CMD) --stop-server||true ifneq (,$(filter $(DEB_HOST_ARCH),i386 amd64)) # Start the sccache server with the right set of options to use GCP SCCACHE_LOG=sccache=debug SCCACHE_ERROR_LOG=$(SCCACHE_PATH)/sccache.log SCCACHE_GCS_KEY_PATH=$(SCCACHE_PATH)/secret-gcp-storage.json SCCACHE_GCS_BUCKET=apt-llvm-org-sccache SCCACHE_GCS_RW_MODE=READ_WRITE $(SCCACHE_CMD) --start-server else # on s390x machine, use a local cache SCCACHE_CACHE_SIZE=20G SCCACHE_LOG=sccache=debug SCCACHE_ERROR_LOG=$(SCCACHE_PATH)/sccache.log SCCACHE_DIR=/opt/sccache/cache/ SCCACHE_DIRECT=true $(SCCACHE_CMD) --start-server endif endif echo "Running tests: $(RUN_TEST)" echo "Using cmake: $(CMAKE_BIN)"; \ LD_LIBRARY_PATH=$$LD_LIBRARY_PATH \ $(PRE_PROCESS_CONF) $(CMAKE_BIN) -S llvm/ -B $(TARGET_BUILD) \ -G Ninja \ -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$(LLVM_VERSION) \ -DLLVM_VERSION_SUFFIX= \ -DCMAKE_SUPPRESS_REGENERATION=ON \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_FLAGS="$(STAGE_1_CFLAGS)" \ -DCMAKE_CXX_FLAGS="$(STAGE_1_CXXFLAGS)" \ -DCMAKE_SHARED_LINKER_FLAGS="$(STAGE_1_LDFLAGS)" \ -DCMAKE_MODULE_LINKER_FLAGS="$(STAGE_1_LDFLAGS)" \ -DCMAKE_EXE_LINKER_FLAGS="$(STAGE_1_LDFLAGS)" \ -DPACKAGE_VENDOR=$(VENDOR) \ -DENABLE_LINKER_BUILD_ID=ON \ -DLLVM_TARGETS_TO_BUILD=Native \ -DLLVM_ENABLE_PROJECTS="$(PROJECTS_LIST)" \ -DLLVM_ENABLE_RUNTIMES="$(RUNTIMES_LIST)" \ -DLLVM_ENABLE_PIC=ON \ -DLLVM_ENABLE_RTTI=ON \ -DLLVM_BUILD_DOCS=OFF \ -DLLVM_INCLUDE_GO_TESTS=OFF \ -DLLVM_USE_RELATIVE_PATHS_IN_FILES=ON \ -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ -DLLVM_ENABLE_CURL=$(if $(filter stage1, $(DEB_BUILD_PROFILES)),OFF,ON) \ -DLLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO=ON \ -DCLANG_PLUGIN_SUPPORT=OFF \ -DCLANG_BUILD_EXAMPLES=OFF \ -DCLANG_DEFAULT_LINKER=ld \ -DCLANG_DEFAULT_RTLIB=libgcc \ -DCOMPILER_RT_BUILD_XRAY=OFF \ -DCOMPILER_RT_INCLUDE_TESTS=OFF \ -DCOMPILER_RT_USE_LIBCXX=OFF \ -DCOMPILER_RT_USE_BUILTINS_LIBRARY=$(COMPILER_RT_USE_BUILTINS_LIBRARY) \ -DLIBUNWIND_INSTALL_LIBRARY=OFF \ -DLIBCXXABI_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \ -DLIBCXXABI_USE_COMPILER_RT=$(LIBCXX_USE_COMPILER_RT) \ -DLIBCXXABI_INSTALL_LIBRARY=OFF \ -DLIBCXX_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \ -DLIBCXX_USE_COMPILER_RT=$(LIBCXX_USE_COMPILER_RT) \ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \ -DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \ -DLIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY=OFF \ -DLIBCXX_INSTALL_LIBRARY=OFF \ -DLIBCXX_INSTALL_MODULES=ON \ -DLLVM_LIBC_GPU_BUILD=ON \ -DBOOTSTRAP_LIBCXX_INSTALL_MODULES=ON \ -DOPENMP_ENABLE_LIBOMP_PROFILING=OFF \ -DOPENMP_ENABLE_LIBOMPTARGET_PROFILING=OFF \ -DLIBOMP_ENABLE_RTTI=OFF \ -DLIBOMP_OMPT_SUPPORT=OFF \ -DCLANG_FORCE_MATCHING_LIBCLANG_SOVERSION=ON \ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ $(CMAKE_EXTRA) \ -DBUILTINS_CMAKE_ARGS="-DCMAKE_C_FLAGS=$(STAGE_1_CFLAGS);-DCMAKE_CXX_FLAGS=$(STAGE_1_CXXFLAGS);-DCMAKE_EXE_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_SHARED_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_MODULE_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_BUILD_TYPE=Release;-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" \ -DRUNTIMES_CMAKE_ARGS="-DCMAKE_C_FLAGS=$(STAGE_1_CFLAGS);-DCMAKE_CXX_FLAGS=$(STAGE_1_CXXFLAGS);-DCMAKE_EXE_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_SHARED_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_MODULE_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_BUILD_TYPE=Release;-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" \ -DCLANG_ENABLE_BOOTSTRAP=ON \ -DCLANG_BOOTSTRAP_TARGETS="$(ENABLED_STAGE2_CMAKE_BUILD_TARGETS)" \ -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_SUPPRESS_REGENERATION;ENABLE_LINKER_BUILD_ID;LLVM_ENABLE_PIC;LLVM_ENABLE_RTTI;LLVM_INCLUDE_GO_TESTS;LLVM_USE_RELATIVE_PATHS_IN_FILES;CLANG_DEFAULT_LINKER;CLANG_DEFAULT_CXX_STDLIB;CLANG_DEFAULT_RTLIB;COMPILER_RT_USE_LIBCXX;COMPILER_RT_USE_BUILTINS_LIBRARY;COMPILER_RT_DEFAULT_TARGET_ONLY;COMPILER_RT_INCLUDE_TESTS;LIBUNWIND_USE_COMPILER_RT;LIBCXXABI_ENABLE_EXCEPTIONS;LIBCXXABI_USE_COMPILER_RT;LIBCXX_USE_COMPILER_RT;LIBCXX_ENABLE_EXCEPTIONS;LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY;LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY;LIBOMP_ENABLE_RTTI;LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN;CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION;CMAKE_C_COMPILER_LAUNCHER;CMAKE_CXX_COMPILER_LAUNCHER;LLVM_LIBC_GPU_BUILD" \ -DBOOTSTRAP_CMAKE_BUILD_TYPE=RelWithDebInfo \ -DBOOTSTRAP_CMAKE_C_FLAGS_RELWITHDEBINFO="$(opt_flags)" \ -DBOOTSTRAP_CMAKE_CXX_FLAGS_RELWITHDEBINFO="$(opt_flags)" \ -DBOOTSTRAP_CMAKE_C_FLAGS="$(STAGE_2_CFLAGS)" \ -DBOOTSTRAP_CMAKE_CXX_FLAGS="$(STAGE_2_CXXFLAGS)" \ -DBOOTSTRAP_CMAKE_SHARED_LINKER_FLAGS="$(STAGE_2_LDFLAGS)" \ -DBOOTSTRAP_CMAKE_MODULE_LINKER_FLAGS="$(STAGE_2_LDFLAGS)" \ -DBOOTSTRAP_CMAKE_EXE_LINKER_FLAGS="$(STAGE_2_LDFLAGS)" \ -DBOOTSTRAP_LLVM_ENABLE_FFI=ON \ -DBOOTSTRAP_LLVM_ENABLE_DUMP=ON \ -DBOOTSTRAP_LLVM_ENABLE_LIBPFM=ON \ -DBOOTSTRAP_LLVM_ENABLE_SPHINX=ON \ -DBOOTSTRAP_CLANG_DEFAULT_PIE_ON_LINUX=ON \ -DBOOTSTRAP_SPHINX_WARNINGS_AS_ERRORS=OFF \ -DBOOTSTRAP_LLVM_USE_RELATIVE_PATHS_IN_FILES=ON \ -DBOOTSTRAP_LLVM_INSTALL_UTILS=ON \ -DBOOTSTRAP_LLVM_VERSION_SUFFIX= \ -DBOOTSTRAP_LLVM_POLLY_LINK_INTO_TOOLS=ON \ -DBOOTSTRAP_LLVM_EXPERIMENTAL_TARGETS_TO_BUILD="M68k;Xtensa" \ -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="M68k;Xtensa" \ -DBOOTSTRAP_LLVM_LINK_LLVM_DYLIB=ON \ -DBOOTSTRAP_LLVM_ENABLE_CURL=$(if $(filter stage1, $(DEB_BUILD_PROFILES)),OFF,ON) \ -DBOOTSTRAP_CLANG_LINK_CLANG_DYLIB=ON \ -DBOOTSTRAP_LIBCLANG_LIBRARY_VERSION=$(SONAME_EXT) \ -DBOOTSTRAP_LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON \ -DBOOTSTRAP_PYTHON_EXECUTABLE=/usr/bin/python3 \ $(BOOTSTRAP_CMAKE_EXTRA) \ -DBOOTSTRAP_BUILTINS_CMAKE_ARGS="-DCMAKE_C_FLAGS=$(STAGE_2_CFLAGS);-DCMAKE_CXX_FLAGS=$(STAGE_2_CXXFLAGS);-DCMAKE_EXE_LINKER_FLAGS=$(STAGE_2_LDFLAGS);-DCMAKE_SHARED_LINKER_FLAGS=$(STAGE_2_LDFLAGS);-DCMAKE_MODULE_LINKER_FLAGS=$(STAGE_2_LDFLAGS);-DCMAKE_BUILD_TYPE=RelWithDebInfo;-DCMAKE_C_FLAGS_RELWITHDEBINFO=$(opt_flags);-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$(opt_flags);-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" \ -DBOOTSTRAP_RUNTIMES_CMAKE_ARGS="-DCMAKE_C_FLAGS=$(STAGE_2_CFLAGS);-DCMAKE_CXX_FLAGS=$(RUNTIMES_CXXFLAGS);-DCMAKE_EXE_LINKER_FLAGS=$(STAGE_2_LDFLAGS) -L$(STAGE_1_LIB_DIR);-DCMAKE_SHARED_LINKER_FLAGS=$(STAGE_2_LDFLAGS) -L$(STAGE_1_LIB_DIR);-DCMAKE_MODULE_LINKER_FLAGS=$(STAGE_2_LDFLAGS) -L$(STAGE_1_LIB_DIR);-DCMAKE_BUILD_TYPE=RelWithDebInfo;-DCMAKE_C_FLAGS_RELWITHDEBINFO=$(opt_flags);-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$(opt_flags);-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" FOUND_VERSION=`grep LLVM_VERSION_STRING build-llvm/include/llvm/Config/llvm-config.h|cut -d\" -f2`; \ if ! echo "$(LLVM_VERSION_FULL)"|grep "$$FOUND_VERSION"; then \ echo "mismatch of version. Found: $$FOUND_VERSION / Expected: $(LLVM_VERSION_FULL)"; \ exit 1; \ fi @mkdir -p stamps touch $@ VERBOSE=-v stamps/debian-full-build: echo "Using cmake: $(CMAKE_BIN)" # linker hack so stage2 can link against stage1 libs at runtime LD_LIBRARY_PATH=$(STAGE_1_LIB_DIR):$$LD_LIBRARY_PATH \ VERBOSE=1 $(TIME_COMMAND) $(PRE_PROCESS) $(CMAKE_BIN) --build $(TARGET_BUILD) -j $(NJOBS) --target stage2 || cat build-llvm/tools/clang/stage2-bins/CMakeFiles/CMakeOutput.log # Check the stage 2 build worked if ! readelf --string-dump .comment $(TARGET_BUILD_STAGE2)/bin/clang 2>&1|grep -q "clang version"; then \ echo "clang hasn't been built using clang. Bye bye. Check that the stage2 build has been done."; \ if test "$(SCAN_BUILD)" = "no"; then \ exit 2; \ fi; \ fi if ldd $(TARGET_BUILD_STAGE2)/lib/libclang-$(LLVM_VERSION).so.1|grep -q libclang-cpp-$(LLVM_VERSION); then \ echo "libclang-$(LLVM_VERSION).so.1 depends on libclang-cpp. Should not be the case"; \ exit 2; \ fi if test -e $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libclang-$(LLVM_VERSION).so.1; then \ echo "libclang-$(LLVM_VERSION).so.1 link is broken"; \ exit 2; \ fi touch $@ stamps/debian-libfuzzer-build: ifeq (${LIBFUZZER_ENABLE},yes) cd $(TARGET_BUILD); \ CFLAGS="$(opt_flags) $(STAGE_2_CFLAGS)"; \ echo $$CFLAGS; \ for sourcefile in $(BASE_PATH)/compiler-rt/lib/fuzzer/*.cpp; do \ $(SCCACHE_CMD) $(STAGE_2_BIN_DIR)/clang++ -c $$CFLAGS -std=c++17 $$sourcefile -IFuzzer || exit 1; \ done; \ ar ruv libFuzzer.a Fuzzer*.o endif touch $@ stamps/debian-libclc-build: # workaround missing files on i386 cd $(TARGET_BUILD_STAGE2) && ninja opt llvm-link llvm-as # Builds libclc mkdir -p libclc/build echo "Using cmake: $(CMAKE_BIN)" cd libclc/build && \ $(CMAKE_BIN) ../ \ -G Ninja \ $(SCCACHE_CMAKE) \ -DCMAKE_C_COMPILER=$(STAGE_2_BIN_DIR)/clang \ -DCMAKE_CXX_COMPILER=$(STAGE_2_BIN_DIR)/clang++ \ -DCMAKE_C_FLAGS="$(opt_flags) $(STAGE_2_CFLAGS)" \ -DCMAKE_CXX_FLAGS="$(opt_flags) $(STAGE_2_CXXFLAGS) -I$(BASE_PATH)/llvm/include" \ -DCMAKE_SHARED_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_MODULE_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_EXE_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_DATADIR=lib \ -DCMAKE_INSTALL_INCLUDEDIR=include \ -DLLVM_CMAKE_DIR=$(STAGE_2_BIN_DIR)/../ \ $(LIBCLC_LLVM_SPIRV) \ -DLIBCLC_TARGETS_TO_BUILD="$(LIBCLC_TARGETS_TO_BUILD)"; \ LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(STAGE_2_LIB_DIR) $(TIME_COMMAND) ninja -j $(NJOBS) $(VERBOSE) ifndef LLVM_SPIRV echo "libclc built without SPIRV (.spv) outputs because llvm-spirv wasn't found" endif touch $@ # Remove some new flags introduced by dpkg 1.22.0; STAGE_2_WASM_CFLAGS := $(filter-out -march=% -mfpu=% -fcf-protection% -mbranch-protection%, $(STAGE_2_CFLAGS)) STAGE_2_WASM_CXXFLAGS := $(filter-out -march=% -mfpu=% -fcf-protection% -mbranch-protection%, $(STAGE_2_CXXFLAGS)) build-wasm/compiler-rt-%: cpu = $(@:build-wasm/compiler-rt-%=%) build-wasm/compiler-rt-%: @echo "Building compiler-rt for $(cpu)" @echo "Using cmake: $(CMAKE_BIN)" mkdir -p "$@" $(CMAKE_BIN) -B "$@" -S compiler-rt/lib/builtins/ \ -G Ninja \ $(SCCACHE_CMAKE) \ -DCMAKE_SYSTEM_NAME=Generic \ -DCMAKE_C_COMPILER_TARGET=$(cpu)-unknown-unknown \ -DCMAKE_CXX_COMPILER_TARGET=$(cpu)-unknown-unknown \ -DCMAKE_ASM_COMPILER_TARGET=$(cpu)-unknown-unknown \ -DCMAKE_C_COMPILER=$(STAGE_2_BIN_DIR)/clang \ -DCMAKE_CXX_COMPILER=$(STAGE_2_BIN_DIR)/clang++ \ -DCMAKE_C_FLAGS="$(opt_flags) $(STAGE_2_WASM_CFLAGS)" \ -DCMAKE_CXX_FLAGS="$(opt_flags) $(STAGE_2_WASM_CXXFLAGS)" \ -DCMAKE_SHARED_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_MODULE_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_EXE_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION) \ -DCMAKE_INSTALL_DATADIR=lib \ -DCMAKE_INSTALL_INCLUDEDIR=include \ -DLLVM_CMAKE_DIR=$(STAGE_2_BIN_DIR)/../ \ -DCOMPILER_RT_STANDALONE_BUILD=ON \ -DCOMPILER_RT_BAREMETAL_BUILD=ON \ -DCOMPILER_RT_INCLUDE_TESTS=OFF \ -DCOMPILER_RT_USE_LIBCXX=OFF \ -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \ -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=$(cpu)-unknown-unknown \ -DCOMPILER_RT_OS_DIR=wasi $(TIME_COMMAND) ninja -C "$@" -j $(NJOBS) $(VERBOSE) ifeq ($(LIBCXX_WASM_ENABLE), no) build-wasm/libcxx-%-wasi: build-wasm/compiler-rt-% @echo "Skipping libcxx-*-wasi on this distro $(DISTRO)" else build-wasm/libcxx-%-wasi: cpu = $(@:build-wasm/libcxx-%-wasi=%) build-wasm/libcxx-%-wasi: build-wasm/compiler-rt-% @echo "Building libcxx for $(cpu)" @echo "Using cmake: $(CMAKE_BIN)" # We need a functioning clang, which in turn requires a linker. We # patch clang to use a versioned wasm-ld (cf. wasm-ld-path.diff), so # create wasm-ld-$(LLVM_VERSION) in the stage2 bin dir manually. cp $(STAGE_2_BIN_DIR)/wasm-ld $(STAGE_2_BIN_DIR)/wasm-ld-$(LLVM_VERSION) # We need a wasm compiler-rt. Depend on the make target that builds it, # and manually copy it to the stage2 lib dir from there mkdir -p \ $(STAGE_2_LIB_DIR)/clang/$(LLVM_VERSION)/lib/wasi/ cp build-wasm/compiler-rt-$(cpu)/lib/wasi/libclang_rt.builtins-$(cpu).a \ $(STAGE_2_LIB_DIR)/clang/$(LLVM_VERSION)/lib/wasi/ # Notes: # - Uses $(LDFLAGS) instead of $(STAGE_2_LDFLAGS), because wasm-ld does not # support --build-id yet. Upstream is working on it, cf. D107662. # - Pass -fno-stack-protector to disable -fstack-protector-strong that is # passed by default, as this is not supported yet in WebAssembly, cf. # https://github.com/WebAssembly/wasi-libc/issues/157 # - Use llvm-ar and llvm-ranlib, as binutils does not currently support # WebAssembly and creates invalid indexes. # - Use LLVM_LIBDIR_SUFFIX to install to /usr/lib/wasm32-wasi. To be # replaced by CMAKE_INSTALL_LIBDIR=lib/$(cpu)-wasi when D130586 # ships. mkdir -p "$@" $(CMAKE_BIN) -B "$@" -S runtimes \ -G Ninja \ $(SCCACHE_CMAKE) \ -DCMAKE_C_COMPILER_WORKS=ON \ -DCMAKE_CXX_COMPILER_WORKS=ON \ -DLLVM_COMPILER_CHECKED=ON \ -DCMAKE_C_COMPILER_TARGET=$(cpu)-unknown-wasi \ -DCMAKE_CXX_COMPILER_TARGET=$(cpu)-unknown-wasi \ -DCMAKE_ASM_COMPILER_TARGET=$(cpu)-unknown-wasi \ -DCMAKE_C_COMPILER=$(STAGE_2_BIN_DIR)/clang \ -DCMAKE_CXX_COMPILER=$(STAGE_2_BIN_DIR)/clang++ \ -DCMAKE_AR=$(STAGE_2_BIN_DIR)/llvm-ar \ -DCMAKE_RANLIB=$(STAGE_2_BIN_DIR)/llvm-ranlib \ -DCMAKE_C_FLAGS="$(opt_flags) $(STAGE_2_WASM_CFLAGS) -fno-stack-protector" \ -DCMAKE_CXX_FLAGS="$(opt_flags) $(STAGE_2_WASM_CXXFLAGS) -fno-stack-protector" \ -DCMAKE_SHARED_LINKER_FLAGS="$(LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_MODULE_LINKER_FLAGS="$(LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$(LLVM_VERSION) \ -DCMAKE_INSTALL_INCLUDEDIR=include/$(cpu)-wasi \ -DLLVM_LIBDIR_SUFFIX=/$(cpu)-wasi \ -DLLVM_CONFIG=$(STAGE_2_BIN_DIR)/llvm-config \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \ -DLIBCXX_USE_COMPILER_RT=ON \ -DLIBCXXABI_USE_COMPILER_RT=ON \ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \ -DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \ -DLIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY=OFF \ -DCMAKE_BUILD_TYPE=RelWithDebugInfo \ -DLIBCXX_CXX_ABI=libcxxabi \ -DLIBCXX_ABI_VERSION=2 \ -DLIBCXX_HAS_MUSL_LIBC:BOOL=ON \ -DLIBCXX_ENABLE_SHARED:BOOL=OFF \ -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL=OFF \ -DLIBCXX_ENABLE_EXCEPTIONS:BOOL=OFF \ -DLIBCXX_ENABLE_FILESYSTEM:BOOL=OFF \ -DLIBCXX_ENABLE_THREADS:BOOL=OFF \ -DLIBCXX_HAS_PTHREAD_API:BOOL=OFF \ -DLIBCXX_HAS_EXTERNAL_THREAD_API:BOOL=OFF \ -DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY:BOOL=OFF \ -DLIBCXXABI_ENABLE_SHARED:BOOL=OFF \ -DLIBCXXABI_ENABLE_EXCEPTIONS:BOOL=OFF \ -DLIBCXXABI_SILENT_TERMINATE:BOOL=ON \ -DLIBCXXABI_ENABLE_THREADS:BOOL=OFF \ -DLIBCXXABI_HAS_PTHREAD_API:BOOL=OFF \ -DLIBCXXABI_HAS_EXTERNAL_THREAD_API:BOOL=OFF \ -DLIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY:BOOL=OFF \ -DLIBCXXABI_USE_LLVM_UNWINDER:BOOL=OFF $(TIME_COMMAND) ninja -C "$@" -j $(NJOBS) $(VERBOSE) endif # Build compiler-rt for wasm32 and wasm64. Build libcxx only for wasm32, as # libcxx requires wasi-libc, which only exists for wasm32 right now. stamps/debian-wasm-build: \ build-wasm/compiler-rt-wasm32 \ build-wasm/libcxx-wasm32-wasi \ build-wasm/compiler-rt-wasm64 touch $@ stamps/sccache-stats: # If we used sccache, shows stats if test -f $(SCCACHE_CMD); then \ ls -al $(SCCACHE_PATH)/; \ mkdir -p /tmp/buildd/source/; \ $(SCCACHE_CMD) --stats-format json --show-stats > /tmp/buildd/source/sccache-stats.json; \ cat /tmp/buildd/source/sccache-stats.json; \ fi touch $@ override_dh_auto_build: \ stamps/debian-full-build \ stamps/debian-libfuzzer-build \ $(if $(filter libclc-%, $(packages)),stamps/debian-libclc-build) \ $(if $(filter %-wasm32 %-wasm64, $(packages)),stamps/debian-wasm-build) \ stamps/sccache-stats override_dh_prep: stamps/build_doc dh_prep ifeq ($(DOC_GENERATION), no) stamps/build_doc: mkdir -p $(TARGET_BUILD)/tools/clang/stage2-bins/docs/ocamldoc/html/ @echo "Don't build doc on this distro $(DISTRO)" else stamps/build_doc: BUILDDIR="_build"; \ ALLSPHINXOPTS="-d $$BUILDDIR/doctrees ."; \ cd $(CURDIR)/llvm/docs && \ sphinx-build -b html $$ALLSPHINXOPTS $$BUILDDIR/html && \ sphinx-build -b man $$ALLSPHINXOPTS $$BUILDDIR/man && \ cd -; \ cd $(CURDIR)/clang/docs && \ sphinx-build -b html $$ALLSPHINXOPTS $$BUILDDIR/html && \ sphinx-build -b man $$ALLSPHINXOPTS $$BUILDDIR/man -(if test "$(OCAML_ENABLE)" = yes; then \ ninja -C "$(TARGET_BUILD_STAGE2)" $(VERBOSE) ocaml_doc; \ fi) ninja -C $(TARGET_BUILD_STAGE2) $(VERBOSE) docs-llvm-html docs-clang-html docs-clang-tools-html docs-clang-tools-man docs-clang-man docs-llvm-man ifeq (${POLLY_ENABLE},yes) ninja -C $(TARGET_BUILD_STAGE2) $(VERBOSE) docs-polly-html docs-polly-man endif # Rename manpages d=$(CURDIR)/llvm/docs/_build/man/; \ if test -d $$d; then \ cd $$d; \ for f in *.1; do \ echo "$$f"|grep $(LLVM_VERSION) || mv $$f `echo $$f|sed "s|\.1|-$(LLVM_VERSION).1|"`; \ done; \ else \ echo "could not find $$d"; \ fi # the clang doc generation only generates clang manpage # When it will do more, we should move that in the loop above cd $(CURDIR)/clang/docs/_build/man/ && mv clang.1 clang-$(LLVM_VERSION).1 # Remove the copy of jquery. See bug #701087 for d in $(TARGET_BUILD_STAGE2)/docs/html/_static/ $(TARGET_BUILD_STAGE2)/tools/clang/docs/html/_static/ $(TARGET_BUILD_STAGE2)/tools/clang/tools/extra/docs/html/_static/; do \ cd $$d && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js && cd -; \ cd $$d && rm -f underscore.js && ln -s /usr/share/javascript/underscore/underscore.js && cd -; \ done mkdir -p debian/man/ ls -al clang/tools/scan-view/bin/scan-view clang/tools/scan-view/bin/scan-view --help || true help2man --no-info --version-string=$(LLVM_VERSION) clang/tools/scan-view/bin/scan-view > debian/man/scan-view-$(LLVM_VERSION).1 || true help2man --no-info --version-string=$(LLVM_VERSION) clang/tools/clang-format/clang-format-diff.py > debian/man/clang-format-diff-$(LLVM_VERSION).1 || true CMDS="llvm-dwarfdump llvm-mc llvm-objdump llvm-rtdyld llvm-size llvm-ranlib lldb clang-format clang clang++ clang-tblgen clang-check clang-cpp clang-tidy clang-apply-replacements clang-rename clang-query pp-trace sancov lli modularize clang-include-fixer find-all-symbols clang-reorder-fields ld.lld llvm-tblgen clang-change-namespace clang-offload-bundler clangd clang-repl git-clang-format run-clang-tidy"; \ for f in $$CMDS; do \ echo "Generating manpage of $$f"; \ LD_LIBRARY_PATH=$(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/:/usr/lib/*/libfakeroot help2man --no-info --version-string=$(LLVM_VERSION) $(TARGET_BUILD_STAGE2)/bin/$$f > debian/man/$$f-$(LLVM_VERSION).1 || true; \ done # Create the following directory regardless as libomp-XX-doc # is Architecture: all mkdir -p openmp/runtime/doc/doxygen/generated/html/ if test "$(OPENMP_ENABLE)" = yes; then \ cd openmp/runtime && doxygen doc/doxygen/config; cd -; \ cd openmp/runtime/doc/doxygen/generated/html/ && rm jquery.js && ln -s /usr/share/javascript/jquery/jquery.js; \ fi touch $@ endif override_dh_auto_install: # Clean up temporary files to make sure the install works rm -rf $(find $(TARGET_BUILD) -wholename '*CMakeFiles*' -not -name CMakeLists.txt -a -name "*.dir" -type d) # install/fast enables a make install without recompiling temporary files LD_LIBRARY_PATH=$(STAGE_2_LIB_DIR):$$LD_LIBRARY_PATH DESTDIR=$(DEB_INST)/ ninja -C $(TARGET_BUILD) $(VERBOSE) stage2-install # Not used on Linux. rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin/argdumper rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/share/clang/clang-format-bbedit.applescript # Remove bat files https://bugs.llvm.org/show_bug.cgi?id=30755 rm -f $(DEB_INST)/usr/share/clang/scan-build-$(LLVM_VERSION)/libexec/*.bat $(DEB_INST)/usr/share/clang/scan-build-$(LLVM_VERSION)/bin/*.bat rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libExampleIRTransforms.a # Remove an example - introduced in https://reviews.llvm.org/D61446 rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libBye.a cp $(TARGET_BUILD_STAGE2)/bin/clang-query $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin # Only run on executable, not script chrpath -d `find $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin/ -type f -executable -exec file -i '{}' \; | grep 'x-executable; charset=binary'|cut -d: -f1` ifeq (,$(filter $(DEB_HOST_ARCH), powerpc)) ifneq (,$(filter $(DEB_HOST_ARCH_OS),linux)) # To fix custom-library-search-path chrpath -d $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)*/lib/linux/*.so || true endif endif if test "$(LIBUNWIND_ENABLE)" = yes; then \ mkdir -p debian/tmp/usr/include/libunwind; \ cp -R libunwind/include/* debian/tmp/usr/include/libunwind/; \ fi : # libomp if test "$(OPENMP_ENABLE)" = yes; then \ cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib; \ ln -s libomp.so.$(SONAME_OPENMP) libomp.so; \ cp libomp.so.$(SONAME_OPENMP) libomp-$(LLVM_VERSION).so.$(SONAME_OPENMP); \ fi # Remove artifact (where compiler-rt is built) # if test -d $(TARGET_BUILD)/tools/clang/runtime/compiler-rt/clang_linux; then \ # cd $(TARGET_BUILD)/tools/clang/runtime/compiler-rt/clang_linux && rm -rf $$(find . -mindepth 2 -maxdepth 2 -type d) && rm -rf $$(find -empty) && rm -rf */.dir; \ # fi mkdir -p $(CURDIR)/debian/clang-$(LLVM_VERSION)/usr/bin/ cp compiler-rt/lib/asan/scripts/asan_symbolize.py $(CURDIR)/debian/clang-$(LLVM_VERSION)/usr/bin/asan_symbolize-$(LLVM_VERSION) ifeq (${LIBFUZZER_ENABLE},yes) mkdir -p $(CURDIR)/debian/libfuzzer-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/ cp -v $(TARGET_BUILD)/libFuzzer.a $(CURDIR)/debian/libfuzzer-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/ endif # Because of hurd, we are more flexible in what we include in libclang-X.Y-rt # but we don't want to install wasi files into libclang-rt as they have their own package # So, we remove this directory from the package rm -f $(CURDIR)/debian/libclang-rt-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/wasi/ # Create this fake directory to make the install libclang-common-dev happy # under the unsupported archs of compiler-rt mkdir -p $(DEB_INST)/usr/lib/clang/$(LLVM_VERSION)/lib mkdir -p $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/lib/ mkdir -p $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/lib/clang_linux/ mkdir -p $(TARGET_BUILD)/tools/clang/runtime/compiler-rt/clang_linux/ mkdir -p $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/share/ # On some archs, the sanitizers are not built. As we explicitly includes some txt files, create # a fake txt to make sure it doesn't fail echo "The *.txt files, if available, contain helper to override some of the errors messages." > $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/README.txt echo "Please visit https://github.com/google/sanitizers/wiki/AddressSanitizer for help" >> $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/README.txt # Path changed. Make a copy of it cp $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/README.txt $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/share/README.txt # Remove things that CMake install but which aren't packaged yet, # or are packaged from the source or build tree. mv $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin/clang-$(LLVM_VERSION) \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin/clang # Probably useless rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/python*/*-packages/six.py rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/local/lib/python*/*-packages/six.py rm -rf $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/build/utils/lit/lit/__pycache__/ \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/build/utils/lit/lit/*/__pycache__/ # workaround issue https://github.com/llvm/llvm-project/issues/57101 find debian/tmp -iname 'libbolt_rt*.a' -path '*/build-llvm/*' -delete # Remove an osx file rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libbolt_rt_instr_osx.a if test -d libclc/build; then \ DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C libclc/build install; \ fi if test -d build-wasm/compiler-rt-wasm32; then \ DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C build-wasm/compiler-rt-wasm32 install; \ fi if test -d build-wasm/compiler-rt-wasm64; then \ DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C build-wasm/compiler-rt-wasm64 install; \ fi if test -d build-wasm/libcxx-wasm32-wasi; then \ DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C build-wasm/libcxx-wasm32-wasi install; \ fi # Rename binaries mkdir -p $(DEB_INST)/usr/bin/ cd $(DEB_INST)/usr/bin/; \ rm -f *; \ for f in ../lib/llvm-$(LLVM_VERSION)/bin/*; do \ ln -s $$f `basename $$f`-$(LLVM_VERSION); \ echo "Link $$f to `basename $$f`-$(LLVM_VERSION)"; \ done # Rename some stuff with the version name cp $(CURDIR)/clang/tools/scan-build/man/scan-build.1 $(CURDIR)/clang/tools/scan-build/man/scan-build-$(LLVM_VERSION).1 # copy the vim files (except that tablegen does not exist for indent VIM_DIRS="ftdetect ftplugin syntax indent"; \ for dir in $$VIM_DIRS; do \ cp -f $(CURDIR)/llvm/utils/vim/$$dir/llvm.vim $(CURDIR)/llvm/utils/vim/$$dir/llvm-$(LLVM_VERSION).vim; \ if test -f $(CURDIR)/llvm/utils/vim/$$dir/tablegen.vim; then \ cp -f $(CURDIR)/llvm/utils/vim/$$dir/tablegen.vim $(CURDIR)/llvm/utils/vim/$$dir/tablegen-$(LLVM_VERSION).vim; \ fi; \ done cp -f $(CURDIR)/llvm/utils/vim/vimrc $(CURDIR)/llvm/utils/vim/llvm-$(LLVM_VERSION)-vimrc cp -f $(CURDIR)/clang/tools/clang-format/clang-format-diff.py $(CURDIR)/clang/tools/clang-format/clang-format-diff-$(LLVM_VERSION) cp -f $(CURDIR)/clang/tools/clang-format/clang-format.py clang/tools/clang-format/clang-format-$(LLVM_VERSION).py rm -rf clang/tools/scan-build-$(LLVM_VERSION) cp -fR $(CURDIR)/clang/tools/scan-build clang/tools/scan-build-$(LLVM_VERSION) rm -rf clang/tools/scan-build-py-$(LLVM_VERSION) cp -fR $(CURDIR)/clang/tools/scan-build-py clang/tools/scan-build-py-$(LLVM_VERSION) chmod +x clang/tools/scan-build-py-$(LLVM_VERSION)/bin/* rm -rf clang/tools/scan-view-$(LLVM_VERSION) cp -fR $(CURDIR)/clang/tools/scan-view clang/tools/scan-view-$(LLVM_VERSION) # Remove some license files rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/include/llvm/Support/LICENSE.TXT # Disable CMake's LLVMExports package validation checks for target files that we may remove. sed -i \ -e '/_\(cmake_import_check_targets\|IMPORT_CHECK_TARGETS\) \(Polly\|sancov\|llvm-omp-device-info\|LibcTableGenUtil\|omptarget\|omp\)/ {s|^|#|}' \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/llvm/LLVMExports-*.cmake # the obscure libLLVM.so.1 file ... sed -i \ -e '/_\(cmake_import_check_targets\|IMPORT_CHECK_TARGETS\) LLVM/ {s|^|#|}' \ -e '/_\(cmake_import_check_targets\|IMPORT_CHECK_TARGETS\)_.*\/libLLVM\.so\.1.*/ {s|^|#|}' \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/llvm/LLVMExports-*.cmake # Also disable mlir-* checks in the cmake sed -i \ -e '/_\(cmake_import_check_targets\|IMPORT_CHECK_TARGETS\) \(mlir-\|MLIR\)/ {s|^|#|}' \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/llvm/LLVMExports-*.cmake sed -i \ -e '/_\(cmake_import_check_files_for\|IMPORT_CHECK_FILES_FOR\)_.*\/bin\/.*/ {s|^|#|}' \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/llvm/LLVMExports-*.cmake \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/clang/ClangTargets-*.cmake sed -i \ -e '/_\(cmake_import_check_files_for\|IMPORT_CHECK_FILES_FOR\)_\(mlir\|Polly\|MLIR\|LibcTableGenUtil\|omp\|omptarget\)/ {s|^|#|}' \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/llvm/LLVMExports-*.cmake \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/clang/ClangTargets-*.cmake # Managed in python*-lldb-X.Y.links.in rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/python*/*-packages/lldb/_lldb.so # Manage the polly files. Sometimes, we build them. Sometimes not. if test "$(POLLY_ENABLE)" = yes; then \ mkdir -p $(CURDIR)/debian/libclang-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/ $(CURDIR)/debian/libpolly-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/include/polly/; \ mv -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libPolly* \ $(CURDIR)/debian/libpolly-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/; \ rm -rf $(CURDIR)/debian/libpolly-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/include/polly; \ mv -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/include/polly/ \ $(CURDIR)/debian/libpolly-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/include/; \ fi mkdir -p $(CURDIR)/debian/usr/share/doc/llvm-$(LLVM_VERSION)-doc/ $(CURDIR)/debian/usr/share/doc/clang-$(LLVM_VERSION)-doc/ if test "$(DOC_GENERATION)" = yes; then \ cp -R $(TARGET_BUILD_STAGE2)/docs/html $(CURDIR)/debian/usr/share/doc/llvm-$(LLVM_VERSION)-doc/; \ cp -R $(TARGET_BUILD_STAGE2)/tools/clang/docs/html $(CURDIR)/debian/usr/share/doc/clang-$(LLVM_VERSION)-doc/; \ cp -R $(TARGET_BUILD_STAGE2)/tools/clang/tools/extra/docs/html $(CURDIR)/debian/usr/share/doc/clang-$(LLVM_VERSION)-doc/clang-extra; \ else \ mkdir -p llvm/docs/_build/html clang/docs/_build/html/ tools/clang/tools/extra/docs/html openmp/runtime/doc/doxygen/generated/html/ debian/man/ clang/docs/_build/man/ llvm/docs/_build/man/; \ rm debian/*$(LLVM_VERSION)*manpages; \ fi # Rename OCaml bindings if test "$(OCAML_ENABLE)" = yes; then \ mkdir -p "$(DEB_INST)$(OCAML_STDLIB_DIR)"; \ mkdir -p "$(DEB_INST)usr/lib/llvm-$(LLVM_VERSION)/docs/ocaml/html/html"; \ mkdir -p "$(DEB_INST)usr/lib/llvm-$(LLVM_VERSION)/share/doc/llvm/ocaml-html/"; \ if test -d "$(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/ocaml"; then \ mv -f "$(DEB_INST)usr/lib/llvm-$(LLVM_VERSION)/lib/ocaml" \ "$(DEB_INST)$(OCAML_STDLIB_DIR)/llvm-$(LLVM_VERSION)"; \ fi; \ fi # For some reasons, from Ubuntu jammy, python stuff are installed in /local/lib, move it back if test -d $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/local/lib/; then \ mv $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/local/lib/* $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/; \ rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/python*/*-packages/six.py; \ ls $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/local/; \ rmdir $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/local/lib; \ rmdir $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/local; \ fi # Disable the python binding for buster. not sure why it regressed # regressed de4364f1ecaa..0745b0c0354a if test "$(DISTRO)" = "buster" -o "$(DEB_HOST_ARCH)" = "mips64el"; then \ mkdir -p $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/share/gdb/python/ompd/; \ touch $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/share/gdb/python/ompd/empty; \ fi if test "$(LLDB_PYTHON_ENABLE)" = no; then \ echo "" > debian/python3-lldb-$(LLVM_VERSION).install; \ fi # Remove some mlir example rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libMyExtensionCh*.a # Delete the target build directory to save some space on the build systems # All the files have been installed in $(CURDIR)/debian/tmp/ already rm -rf $(TARGET_BUILD) # for apt.llvm.org and prerelease versions, we are depending on the # upstream version. After release, assume that the ABIs don't change # anymore with the point releases (X.Y.1, Y.Y.2, ...) LLVM_RELEASE := $(LLVM_EPOCH)$(LLVM_VERSION).$(LLVM_VERSION_MINOR).0 override_dh_makeshlibs: ifneq (,$(findstring ~,$(PKG_VERSION))) dh_makeshlibs -plibclang$(SONAME_EXT)-$(LLVM_VERSION) dh_makeshlibs -pliblldb-$(LLVM_VERSION) dh_makeshlibs -plibllvm$(LLVM_VERSION) dh_makeshlibs -plibomp$(SONAME_OPENMP)-$(LLVM_VERSION) else dh_makeshlibs -plibclang$(SONAME_EXT)-$(LLVM_VERSION) \ '-Vlibclang$(SONAME_EXT)-$(LLVM_VERSION) (>= $(LLVM_RELEASE))' dh_makeshlibs -pliblldb-$(LLVM_VERSION) \ '-Vliblldb-$(LLVM_VERSION) (>= $(LLVM_RELEASE))' dh_makeshlibs -plibllvm$(LLVM_VERSION) \ '-Vlibllvm$(LLVM_VERSION) (>= $(LLVM_RELEASE))' dh_makeshlibs -plibomp$(SONAME_OPENMP)-$(LLVM_VERSION) \ '-Vlibomp$(SONAME_OPENMP)-$(LLVM_VERSION) (>= $(LLVM_RELEASE))' endif dh_makeshlibs --remaining-packages -V override_dh_shlibdeps: # Ignore asan libraries. They would trigger dependencies to multiarch libraries dh_shlibdeps -l$(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/ -Xlibclang_rt.asan -Xlibclang_rt.asan -Xlibclang_rt.asan-*.so -Xlibclang_rt.asan-*.so override_dh_installman: if test -f lld/docs/ld.lld.1; then \ mv lld/docs/ld.lld.1 lld/docs/ld.lld-$(LLVM_VERSION).1; \ fi dh_installman # Make sure that lli manpage is only in llvm-3.2-runtime (See #697117) rm -f $(CURDIR)/debian/llvm-$(LLVM_VERSION)/usr/share/man/man1/lli* override_dh_strip: : # running out of diskspace on the buildds find $(TARGET_BUILD) -name '*.o' -o -name '*.a' -type f | xargs -r rm -f ifeq (0, $(strip $(shell dpkg --compare-versions $(DH_VERSION) ge 9.20160114; echo $$?))) : # If we don't have the right version of debhelper, don't run the option dh_strip -p libclang$(SONAME_EXT)-$(LLVM_VERSION) --dbgsym-migration='libclang$(SONAME_EXT)-$(LLVM_VERSION)-dbg' dh_strip -p libllvm$(LLVM_VERSION) --dbgsym-migration='libllvm$(LLVM_VERSION)-dbg' dh_strip -p liblldb-$(LLVM_VERSION) --dbgsym-migration='liblldb-$(LLVM_VERSION)-dbg' dh_strip -p libomp$(SONAME_OPENMP)-$(LLVM_VERSION) --dbgsym-migration='libomp$(SONAME_OPENMP)-$(LLVM_VERSION)-dbg' endif # ifeq (${LLD_ENABLE},yes) # PATH=$(CURDIR)/:$$PATH dh_strip -p liblld-$(LLVM_VERSION) --dbg-package=liblld-$(LLVM_VERSION)-dbg # endif ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' binutils) lt 2.31.1-11 ; echo $$?),0) : # building with clang, binutils/strip has hard time stripping some libs because of : # https://sourceware.org/bugzilla/show_bug.cgi?id=23788 : # use llvm-strip instead : # Workaround some issues with stripping by using llvm's if test ! -f $(CURDIR)/strip; then \ ln -s $(CURDIR)/debian/llvm-$(LLVM_VERSION)/usr/lib/llvm-$(LLVM_VERSION)/bin/llvm-strip $(CURDIR)/strip; \ fi ls -al $(CURDIR)/debian/.debhelper/*/dbgsym-root/usr/lib/debug/.build-id/*/*|| true : # On some old version of Debian (stretch) and Ubuntu, Rules-Requires-Root isn't supported : # Sometime, it fails because of chown: changing ownership of 'debian/.debhelper/clang-7/dbgsym-root/usr/lib/debug/.build-id/37/ba506ae9d2f82219bf5c552f7c09853052b2b0.debug': Operation not permitted : # Therefore, continue when we encounter an error PATH=$(CURDIR)/:$$PATH LD_LIBRARY_PATH=$(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/:/usr/lib/*/libfakeroot dh_strip -a -v || true : # Remove the workaround rm $(CURDIR)/strip : # for some reasons, the +x might be removed chmod -f +x $(CURDIR)/debian/*/usr/lib/llvm-$(LLVM_VERSION)/bin/* || true else # GNU strip doesn't recognize WebAssembly binaries, and actually corrupts them. # llvm-strip (as of 15.0.2) fails with --strip-debug (but works with --strip-all) dh_strip -a -v -Xlibclang_rt.builtins-wasm32.a -Xlibclang_rt.builtins-wasm64.a -Xusr/lib/wasm32-wasi endif override_dh_install: : # fix libLLVM.so.1 install, install it under the SONAME -ls -l debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM*.so* test -f debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM.so.1 if [ -f debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM.so.1 ] && [ ! -h debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM.so.1 ]; then \ soname=$$(objdump -p debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM.so.1 | awk '/ *SONAME / {print $$2}'); \ rm -f debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/$$soname; \ mv debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM.so.1 debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/$$soname; \ ln -sf $$soname debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM-$(LLVM_VERSION).so; \ ln -sf $$soname debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM.so; \ fi ifeq (${POLLY_ENABLE},yes) # only for arch:any builds ifneq (,$(filter libpolly-$(LLVM_VERSION)-dev, $(packages))) dh_install -p libpolly-$(LLVM_VERSION)-dev usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/polly/*.cmake usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/polly # On old Debian & Ubuntu, removing the files is necessary rm -rf debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/polly/*.cmake else rm -rf $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/polly/*.cmake endif endif dh_install --fail-missing ${skip_packages} # Move the libc++ abi files from libc++ to libc++-abi for the wasm32 packages # These packages are arch: all, so only do so when the packages are built ifneq (,$(filter libc++-$(LLVM_VERSION)-dev-wasm32, $(packages))) mkdir -p $(CURDIR)/debian/libc++abi-$(LLVM_VERSION)-dev-wasm32/usr/lib/llvm-$(LLVM_VERSION)/include/wasm32-wasi/c++/v1 if test -f $(CURDIR)/debian/libc++-$(LLVM_VERSION)-dev-wasm32/usr/lib/llvm-$(LLVM_VERSION)/include/wasm32-wasi/c++/v1/__cxxabi_config.h; then \ mv $(CURDIR)/debian/libc++-$(LLVM_VERSION)-dev-wasm32/usr/lib/llvm-$(LLVM_VERSION)/include/wasm32-wasi/c++/v1/__cxxabi_config.h \ $(CURDIR)/debian/libc++abi-$(LLVM_VERSION)-dev-wasm32/usr/lib/llvm-$(LLVM_VERSION)/include/wasm32-wasi/c++/v1/__cxxabi_config.h; \ mv $(CURDIR)/debian/libc++-$(LLVM_VERSION)-dev-wasm32/usr/lib/llvm-$(LLVM_VERSION)/include/wasm32-wasi/c++/v1/cxxabi.h \ $(CURDIR)/debian/libc++abi-$(LLVM_VERSION)-dev-wasm32/usr/lib/llvm-$(LLVM_VERSION)/include/wasm32-wasi/c++/v1/cxxabi.h; \ fi endif # Because of hurd, we are more flexible in what we include in libclang-X.Y-rt # but we don't want to install wasi files into libclang-rt as they have their own package # So, we remove this directory from the package rm -fr $(CURDIR)/debian/libclang-rt-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/lib/wasi/ if [ -d debian/llvm-$(LLVM_VERSION)/usr/share/doc/llvm-$(LLVM_VERSION) ]; then \ for svg in usage-*.svg; do \ [ -f $$svg ] || continue; \ xz -9v $$svg; \ cp -p $$svg.xz debian/llvm-$(LLVM_VERSION)/usr/share/doc/llvm-$(LLVM_VERSION)/.; \ done; \ fi stamps/repack_a_llvm_ir: ifeq (${LTO_ENABLE},yes) # with LTO, .a contains llvm ir instead of native code. So, recompile them NJOBS="$(NJOBS)" P_TO_LLVM="$(CURDIR)" VERSION=$(LLVM_VERSION) bash -v debian/llvm-compile-lto-elf.sh $(CXXFLAGS_EXTRA) endif touch $@ override_dh_installdeb: stamps/repack_a_llvm_ir # Managed by the package dh_installdeb -a rm -f $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/python*/*-packages/lldb/__init__.pyc $(CURDIR)/debian/python*-lldb-$(LLVM_VERSION)/usr/lib/llvm-$(LLVM_VERSION)/lib/python*/*-packages/lldb/__init__.pyc rm -f $(CURDIR)/debian/clang-$(LLVM_VERSION)-examples/usr/share/doc/clang-$(LLVM_VERSION)-examples/examples/*Make* # the openmp header files moved to the same path as lib clang headers. # To make sure they aren't conflicting ( https://bugs.llvm.org/show_bug.cgi?id=46977 ) # Remove them from the libclang-common package rm -f $(CURDIR)/debian/libclang-common-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)/include/omp*.h # Remove some libc++ abi files in the libc++ file. See bug #969274 rm -f $(CURDIR)/debian/libc++-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/include/c++/__cxxabi_config.h $(CURDIR)/debian/libc++-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/include/c++/cxxabi.h # Remove auto generated python pyc find $(CURDIR)/debian/llvm-$(LLVM_VERSION)-tools/usr/lib/llvm-$(LLVM_VERSION)/ -name '*.pyc' | xargs -r rm -f ifeq (${RUN_TEST},yes) # List of the archs we know we have 100 % tests working ARCH_LLVM_TEST_OK := i386 amd64 override_dh_auto_test: echo "Running tests: $(RUN_TEST)" # LLVM tests ifneq (,$(findstring $(DEB_HOST_ARCH),$(ARCH_LLVM_TEST_OK))) # logs the output to check-llvm_build_log.txt for validation through autopkgtest ninja $(VERBOSE) -C $(TARGET_BUILD) stage2-check-llvm | tee check-llvm_build_log.txt else ninja $(VERBOSE) -C $(TARGET_BUILD) stage2-check-llvm || true endif # Clang tests ninja $(VERBOSE) -C $(TARGET_BUILD) stage2-check-clang || true # Clang extra tests (ex: clang-tidy) ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-clang-tools || true # LLD tests ifeq (${LLD_ENABLE},yes) ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-lld || true endif # Sanitizer ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-sanitizer || true # Libcxx ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-libcxx || true # Libc ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-libc || true # Libcxxabi ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-libcxxabi || true # MLIR ifeq (,$(filter $(DEB_HOST_ARCH), armel armhf i386 x32)) # Do not run MLIR test on i386 because of # https://github.com/llvm/llvm-project/issues/58357 ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-mlir || true endif # Libclc ninja $(VERBOSE) -C libclc/build test || true # LLDB tests ifeq (,$(filter $(DEB_HOST_ARCH), $(LLDB_DISABLE_ARCHS) armhf armel)) ifneq (,$(filter codecoverage,$(DEB_BUILD_OPTIONS))) # Create a symlink to run the testsuite: see https://bugs.archlinux.org/task/50759 cd $(CURDIR)/$(TARGET_BUILD)/lib/python*/*-packages/; \ if test ! -e _lldb.so; then \ ln -s lldb/_lldb.so; \ fi if test "$(CODECOVERAGE)" = "no"; then \ LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(CURDIR)/$(TARGET_BUILD)/lib/ ninja $(VERBOSE) -C $(TARGET_BUILD) check-lldb || true; \ fi # remove the workaround rm $(CURDIR)/$(TARGET_BUILD)/lib/python*/*-packages/_lldb.so endif endif # Polly tests #ifeq (${POLLY_ENABLE},yes) # ninja -C $(TARGET_BUILD) check-polly || true #endif # Managed by debian build system rm -f $(CURDIR)/$(TARGET_BUILD)/lib/python*/*-packages/lldb/_lldb.so # The compression of the code coverage report is done in the # hook B21GetCoverageResults on the server if test "$(CODECOVERAGE)" = "yes"; then \ REPORT=reports/llvm-toolchain.info; \ mkdir -p reports/; \ lcov --directory $(TARGET_BUILD)/ --capture --ignore-errors source --output-file $$REPORT; \ lcov --remove $$REPORT "/usr*" -o $$REPORT; \ genhtml -o reports/coverage --show-details --highlight --legend $$REPORT; \ chmod 0755 `find reports/coverage -type d`; \ chmod 0644 `find reports/coverage -type f`; \ fi else override_dh_auto_test: @echo "Skipping tests" endif override_dh_builddeb: dh_builddeb ${skip_packages} override_dh_gencontrol: stamps/sccache-stats dh_gencontrol ${skip_packages} -- $(control_vars) override_dh_auto_clean: rm -rf $(TARGET_BUILD) llvm/docs/_build/ clang/docs/_build tools/clang/docs/_html/ # QA tools rm -rf cov-int/ reports/ rm -f `ls debian/*.in|grep -v control.in|sed -e "s|.in$$||g"` find utils -name '*.pyc' | xargs -r rm -f # Use -I because a test has a space in its name find lldb/test -iname '*.pyc' | xargs -I{} -r rm -f {} rm -f $(CURDIR)/utils/vim/llvm-$(LLVM_VERSION).vim $(CURDIR)/utils/vim/tablegen-$(LLVM_VERSION).vim rm -f $(CURDIR)/clang/tools/clang-format/clang-format-diff-$(LLVM_VERSION) rm -f $(CURDIR)/clang/tools/clang-format/clang-format-$(LLVM_VERSION).py rm -rf libclc/build rm -rf build-wasm if test -f lld/docs/ld.lld-$(LLVM_VERSION).1; then \ mv lld/docs/ld.lld-$(LLVM_VERSION).1 lld/docs/ld.lld.1; \ fi for f in debian/*.in; do \ if ! echo $$f|grep control; then \ f2=$$(echo $$f | sed 's/\.in$$//;s/X\.Y/$(LLVM_VERSION)/'); \ rm -f $$f2; \ fi; \ done if test "$(SCAN_BUILD)" = "yes"; then \ patch -f -R -p1 < debian/patches/on-the-fly/use-scan-build-runtimes.diff||true; \ fi : # for some reason, the docs are written to debian/usr and debian/man ... rm -rf debian/usr debian/man : # remove extra stamps rm -f override_dh_auto_install rm -rf stamps rm -f usage-*.svg* .PHONY: override_dh_strip preconfigure