avidyalalala / sunpinyin

Automatically exported from code.google.com/p/sunpinyin
0 stars 0 forks source link

[Patch] breaks if LDFLAGS in environment contains multiple words #291

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If LDFLAGS is set in the environment to a string composed of multiple
words when building sunpinyin, then scons will fail to detect C library
functions because it tries to build test programs with a command of the
form:

  gcc "-Wl,... -Wl,..." -Wl,...

... i.e. the original value of LDFLAGS is passed in as a single argument
rather than split on whitespace in the usual way.  This happens because
PassVariables copies LDFLAGS from the process environment into LINKFLAGS
in the SCons environment, and then uses env.Append(LINKFLAGS=[...]),
which ends up constructing a list whose first element is the entire
value of LDFLAGS.

The problem is fairly obscure, but the fix is fortunately
straightforward: split the value of LDFLAGS.

  * If LDFLAGS is set in the environment, split it on whitespace since we
    later want to append lists to it.  This stops function detection going
    horribly wrong if LDFLAGS contains more than one word.

diff -Nru sunpinyin-2.0.3/debian/patches/fix-ldflags-handling.patch 
sunpinyin-2.0.3/debian/patches/fix-ldflags-handling.patch
--- sunpinyin-2.0.3/debian/patches/fix-ldflags-handling.patch   1970-01-01 
01:00:00.000000000 +0100
+++ sunpinyin-2.0.3/debian/patches/fix-ldflags-handling.patch   2011-10-20 
14:45:35.000000000 +0100
@@ -0,0 +1,24 @@
+Description: Split LDFLAGS on whitespace
+ If LDFLAGS is set in the environment, split it on whitespace since we later
+ want to append lists to it.  This stops function detection going horribly
+ wrong if LDFLAGS contains more than one word.
+Author: Colin Watson <cjwatson@ubuntu.com>
+Forwarded: no
+Last-Update: 2011-10-20
+
+Index: b/SConstruct
+===================================================================
+--- a/SConstruct
++++ b/SConstruct
+@@ -158,7 +158,10 @@
+     for (x, y) in envvar:
+         if x in os.environ:
+             print 'Warning: you\'ve set %s in the environmental variable!' % x
+-            env[y] = os.environ[x]
++            if y == 'LINKFLAGS':
++                env[y] = os.environ[x].split()
++            else:
++                env[y] = os.environ[x]
+     
+ env = CreateEnvironment()
+ opts.Update(env)
diff -Nru sunpinyin-2.0.3/debian/patches/series 
sunpinyin-2.0.3/debian/patches/series
--- sunpinyin-2.0.3/debian/patches/series   2011-09-27 15:03:57.000000000 +0100
+++ sunpinyin-2.0.3/debian/patches/series   2011-10-20 14:32:59.000000000 +0100
@@ -3,3 +3,4 @@
 fix-ftbfs-on-sh.patch
 fix-ftbfs-on-mipsel.patch
 remove-10-candidate-words-limitation.patch
+fix-ldflags-handling.patch

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=646001

Original issue reported on code.google.com by wzss...@gmail.com on 30 Mar 2012 at 7:20