Re: [PATCH] Fix clang linking if flags contain '-mllvm $arg'.

Brooks Moses <[email protected]>
Newsgroups gmane.comp.gnu.libtool.patches
Message-ID <[email protected]>
On 12/25/2012 08:09 PM, Johannes Obermayr wrote:
> Fixes:
> http://llvm.org/bugs/show_bug.cgi?id=14716

The idea is right, but commented-out code is not the right way to explain 
this in a finished patch.

I confirmed with a local LLVM programmer that what's going on here is that 
-mllvm is for passing things through from Clang to LLVM -- and, since Clang 
never uses LLVM for linking, the -mllvm options are always irrelevant for 
linking.

(He also pointed out that anyone using -mllvm with libtool is probably doing 
it wrong anyway; -mllvm is meant as an escape hatch for experimental stuff 
that isn't yet reflected in the Clang front-end, and supported things like 
-mllvm -vectorize should be replaced by the equivalent Clang option.)

Thus, I've committed the attached revision of your patch, which explains in 
a short rewritten comment why the "mllvm" handler is empty.

Thanks!
- Brooks
0001-libtool-Discard-mllvm-arg-options-when-linking.patch (text/x-patch, 1.5 KB)
From d9a35fe9d3508b5c0d56e7f2ec80fc05e8415fa3 Mon Sep 17 00:00:00 2001
From: Brooks Moses <[email protected]>
Date: Wed, 9 Oct 2013 12:32:48 -0700
Subject: [PATCH] libtool: Discard "-mllvm $arg" options when linking.

Clang accepts options of the form "-mllvm $arg", and passes the
argument as an option to LLVM.  These options caused problems
for Libtool when linking; in some cases, the -mllvm option is
passed through but the corresponding argument is dropped.  (See
for example http://llvm.org/bugs/show_bug.cgi?id=14716.)

This patch resolves the issue by explicitly matching -mllvm and
taking an argument.  Since Clang never uses LLVM for linking,
the matched "-mllvm $arg" option is irrelevant for the link
step, and we can simply discard it once we've recognized it.

Co-authored-by: Johannes Obermayr <[email protected]>
Copyright-paperwork-exempt: Yes
---
 build-aux/ltmain.in | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index f22ac05..363ce9b 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -4739,6 +4739,12 @@ func_mode_link ()
 	  prev=
 	  continue
 	  ;;
+	mllvm)
+	  # Clang does not use LLVM to link, so we can simply discard any
+	  # '-mllvm $arg' options when doing the link step.
+	  prev=
+	  continue
+	  ;;
 	objectlist)
 	  if test -f "$arg"; then
 	    save_arg=$arg
@@ -5077,6 +5083,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -mllvm)
+	prev=mllvm
+	continue
+	;;
+
       -module)
 	module=yes
 	continue
-- 
1.8.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.