libtool: Recognise additional linker commandline options passed by clang

Message ID 20220309205737.3796035-1-raj.khem@gmail.com
State Accepted, archived
Commit 6d2035b9017552f050e53add0b3ef4090141fc5e
Headers show
Series libtool: Recognise additional linker commandline options passed by clang | expand

Commit Message

Khem Raj March 9, 2022, 8:57 p.m. UTC
Like stdlib, these options are also used to select runtime libraries by
clang driver

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 .../libtool/libtool-2.4.6.inc                 |  1 +
 ...in.in-Parse-additional-clang-options.patch | 37 +++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 meta/recipes-devtools/libtool/libtool/0001-ltmain.in-Parse-additional-clang-options.patch

Patch

diff --git a/meta/recipes-devtools/libtool/libtool-2.4.6.inc b/meta/recipes-devtools/libtool/libtool-2.4.6.inc
index 2b5fd8fd942..ad6f5e6b6eb 100644
--- a/meta/recipes-devtools/libtool/libtool-2.4.6.inc
+++ b/meta/recipes-devtools/libtool/libtool-2.4.6.inc
@@ -26,6 +26,7 @@  SRC_URI = "${GNU_MIRROR}/libtool/libtool-${PV}.tar.gz \
            file://0012-libtool.m4-For-reproducibility-stop-encoding-hostnam.patch \
            file://libool.m4-add-ARFLAGS-variable.patch \
            file://ARFLAGS-use-cr-instead-of-cru-by-default.patch \
+           file://0001-ltmain.in-Parse-additional-clang-options.patch \
           "
 
 SRC_URI[md5sum] = "addf44b646ddb4e3919805aa88fa7c5e"
diff --git a/meta/recipes-devtools/libtool/libtool/0001-ltmain.in-Parse-additional-clang-options.patch b/meta/recipes-devtools/libtool/libtool/0001-ltmain.in-Parse-additional-clang-options.patch
new file mode 100644
index 00000000000..d59b5a834eb
--- /dev/null
+++ b/meta/recipes-devtools/libtool/libtool/0001-ltmain.in-Parse-additional-clang-options.patch
@@ -0,0 +1,37 @@ 
+From c3b90d6107a1b638477d5f4dcee48af289647af7 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 9 Mar 2022 12:52:51 -0800
+Subject: [PATCH] ltmain.in: Parse additional clang options
+
+clang uses -rtlib and --unwindlib to select proper compiler runtime in
+some cases. There fore pass these options to linker when found in
+ldflags
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ build-aux/ltmain.in | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
+index 6a7bb72..c355c0c 100644
+--- a/build-aux/ltmain.in
++++ b/build-aux/ltmain.in
+@@ -5423,10 +5423,13 @@ func_mode_link ()
+       # --sysroot=*          for sysroot support
+       # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+       # -stdlib=*            select c++ std lib with clang
++      # -rtlib=*             select c runtime lib with clang
++      # --unwindlib=*        select unwinder library with clang
+       # -f*-prefix-map*      needed for lto linking
+       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
+-      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*|-f*-prefix-map*)
++      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
++      -rtlib=*|--unwindlib=*|-f*-prefix-map*)
+         func_quote_for_eval "$arg"
+ 	arg=$func_quote_for_eval_result
+         func_append compile_command " $arg"
+-- 
+2.35.1
+