Package: src:llvm-toolchain-12
Version: 1:12.0.0~++rc5-1
Tags: patch

The files libLTO.so.12 LLVMgold.so and LLVMPolly.so are currently shipped in
llvm-12-dev.  Shipping plugins in a -dev package is not ideal, and these are
required when calling clang -flto.

As discussed, split them out into it's own package, and let both clang-12 and
llvm-12 depend on it. Note that the new install file need x permissions.

Maybe also ship the linker tools llvm-{ar,ranlib,objcopy,nm} in that new 
package.

Two unrelated changes in the patch:
 - better clean the debian directory
 - build with optimize=-lto.

  * Split out a llvm-12-linker-tools package, and let both clang-12 and
    llvm-12 depend on it.

  * Clean files generated from *.in files, and clean debian/{man,usr}.

diff -Nru llvm-toolchain-12-12.0.0~++rc5/debian/control llvm-toolchain-12-12.0.0~++rc5/debian/control
--- llvm-toolchain-12-12.0.0~++rc5/debian/control	2021-03-29 11:35:05.000000000 +0000
+++ llvm-toolchain-12-12.0.0~++rc5/debian/control	2021-04-14 11:26:45.000000000 +0000
@@ -31,10 +31,13 @@
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, ${dep:devlibs},
  ${dep:devlibs-objc}, libclang-common-12-dev (= ${binary:Version}),
+ llvm-12-linker-tools (= ${binary:Version}),
  libclang1-12 (= ${binary:Version}), libc6-dev, binutils
 Provides: c-compiler, objc-compiler, c++-compiler
 Recommends: llvm-12-dev, python3, libomp-12-dev
 Suggests: clang-12-doc
+Breaks: llvm-12-dev (<< 1:12.0.0~++rc5-1ubuntu1)
+Replaces: llvm-12-dev (<< 1:12.0.0~++rc5-1ubuntu1)
 Description: C, C++ and Objective-C compiler
  Clang project is a C, C++, Objective C and Objective C++ front-end
  based on the LLVM compiler. Its goal is to offer a replacement to the
@@ -279,10 +282,24 @@
  .
  This package contains the LLVM runtime library.
 
+Package: llvm-12-linker-tools
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Breaks: llvm-12-dev (<< 1:12.0.0~++rc5-1ubuntu2), clang-12 (<< 1:12.0.0~++rc5-1ubuntu2)
+Replaces: llvm-12-dev (<< 1:12.0.0~++rc5-1ubuntu2), clang-12 (<< 1:12.0.0~++rc5-1ubuntu2)
+Description: Modular compiler and toolchain technologies
+ LLVM is a collection of libraries and tools that make it easy to build
+ compilers, optimizers, just-in-time code generators, and many other
+ compiler-related programs.
+ .
+ This package contains the LLVMgold and LLVMPolly linker plugins.
+
 Package: llvm-12
 Architecture: any
 Suggests: llvm-12-doc
-Depends: llvm-12-runtime (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Depends: llvm-12-runtime (= ${binary:Version}),
+ llvm-12-linker-tools (= ${binary:Version}),
+ ${shlibs:Depends}, ${misc:Depends}
 Recommends: llvm-12-dev
 Description: Modular compiler and toolchain technologies
  LLVM is a collection of libraries and tools that make it easy to build
diff -Nru llvm-toolchain-12-12.0.0~++rc5/debian/llvm-X.Y-dev.install.in llvm-toolchain-12-12.0.0~++rc5/debian/llvm-X.Y-dev.install.in
--- llvm-toolchain-12-12.0.0~++rc5/debian/llvm-X.Y-dev.install.in	2021-01-27 14:48:30.000000000 +0000
+++ llvm-toolchain-12-12.0.0~++rc5/debian/llvm-X.Y-dev.install.in	2021-04-13 11:31:04.000000000 +0000
@@ -2,10 +2,9 @@
 
 usr/lib/llvm-@LLVM_VERSION@/lib/libLLVM*.a
 #usr/lib/llvm-@LLVM_VERSION@/lib/libllvm*.a
-[!powerpc !powerpcspe] usr/lib/llvm-@LLVM_VERSION@/lib/LLVM*.so
 usr/lib/llvm-@LLVM_VERSION@/lib/libLLVM.so
 usr/lib/llvm-@LLVM_VERSION@/lib/libLLVM-@LLVM_VERSION@*.so
-usr/lib/llvm-@LLVM_VERSION@/lib/libLTO.*
+usr/lib/llvm-@LLVM_VERSION@/lib/libLTO.so
 usr/lib/llvm-@LLVM_VERSION@/lib/libRemarks.*
 usr/lib/llvm-@LLVM_VERSION@/include/llvm/      usr/include/llvm-@LLVM_VERSION@/
 usr/lib/llvm-@LLVM_VERSION@/include/llvm-c/	usr/include/llvm-c-@LLVM_VERSION@/
diff -Nru llvm-toolchain-12-12.0.0~++rc5/debian/llvm-X.Y-linker-tools.install.in llvm-toolchain-12-12.0.0~++rc5/debian/llvm-X.Y-linker-tools.install.in
--- llvm-toolchain-12-12.0.0~++rc5/debian/llvm-X.Y-linker-tools.install.in	1970-01-01 00:00:00.000000000 +0000
+++ llvm-toolchain-12-12.0.0~++rc5/debian/llvm-X.Y-linker-tools.install.in	2021-04-14 11:28:58.000000000 +0000
@@ -0,0 +1,4 @@
+#!/usr/bin/dh-exec
+
+usr/lib/llvm-@LLVM_VERSION@/lib/libLTO.so.@LLVM_VERSION@
+[!powerpc !powerpcspe] usr/lib/llvm-@LLVM_VERSION@/lib/LLVM*.so
diff -Nru llvm-toolchain-12-12.0.0~++rc5/debian/patches/clang-default-x86-64-v2.diff llvm-toolchain-12-12.0.0~++rc5/debian/patches/clang-default-x86-64-v2.diff
--- llvm-toolchain-12-12.0.0~++rc5/debian/patches/clang-default-x86-64-v2.diff	1970-01-01 00:00:00.000000000 +0000
+++ llvm-toolchain-12-12.0.0~++rc5/debian/patches/clang-default-x86-64-v2.diff	2021-04-13 11:31:04.000000000 +0000
@@ -0,0 +1,11 @@
+--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
++++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
+@@ -91,7 +91,7 @@ std::string x86::getX86TargetCPU(const A
+ 
+   // Everything else goes to x86-64 in 64-bit mode.
+   if (Is64Bit)
+-    return "x86-64";
++    return "x86-64-v2";
+ 
+   switch (Triple.getOS()) {
+   case llvm::Triple::NetBSD:
diff -Nru llvm-toolchain-12-12.0.0~++rc5/debian/rules llvm-toolchain-12-12.0.0~++rc5/debian/rules
--- llvm-toolchain-12-12.0.0~++rc5/debian/rules	2021-04-05 10:01:22.000000000 +0000
+++ llvm-toolchain-12-12.0.0~++rc5/debian/rules	2021-04-14 12:25:40.000000000 +0000
@@ -65,7 +65,7 @@
 
 # Ensure fixfilepath feature is disabled.  The fixfilepath feature
 # sets a -ffile-prefix-map flag, which is only supported in clang-10.
-export DEB_BUILD_MAINT_OPTIONS=reproducible=-fixfilepath
+export DEB_BUILD_MAINT_OPTIONS=reproducible=-fixfilepath optimize=-lto
 
 # Cxx flags for building libcxx and libcxxabi
 LIBCXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
@@ -329,7 +329,13 @@
 	done
 
 	# Make install file executable for dh-exec
-	chmod +x debian/llvm-$(LLVM_VERSION)-dev.install debian/libclang-common-$(LLVM_VERSION)-dev.install debian/clang-tools-$(LLVM_VERSION).install debian/libomp-$(LLVM_VERSION)-dev.install
+	chmod +x \
+		debian/clang-$(LLVM_VERSION).install \
+		debian/clang-tools-$(LLVM_VERSION).install \
+		debian/libclang-common-$(LLVM_VERSION)-dev.install \
+		debian/libomp-$(LLVM_VERSION)-dev.install \
+		debian/llvm-$(LLVM_VERSION)-dev.install \
+		debian/llvm-$(LLVM_VERSION)-linker-tools.install
 
 	# DH doesn't support the [power ...] in install on Ubuntu trusty
 	# fails with cp: cannot stat 'debian/tmp/[!powerpc': No such file or directory
@@ -910,5 +916,11 @@
 	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 \
+		f2=$$(echo $$f | sed 's/\.in$$//;s/X\.Y/$(LLVM_VERSION)/'); \
+		rm -f $$f2; \
+	done
+	: # for some reason, the docs are written to debian/usr and debian/man ...
+	rm -rf debian/usr debian/man
 
 .PHONY: override_dh_strip preconfigure debian-full-build debian-libfuzzer-build debian-libcxx-build debian-libcxxabi-build

Reply via email to