Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#2661 closed defect (fixed)

handle space in "-L /path/to/lib" output from python-config

Reported by: jinmei Owned by: jinmei
Priority: medium Milestone: Sprint-20130219
Component: build system Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: Core Feature Depending on Ticket:
Estimated Difficulty: 2 Add Hours to Ticket: 0
Total Hours: 1.5 Internal?: no

Description

On some instance of Solaris (and probably with a particular package
system), python(3)-config --ldflags inserts a space between '-L'
and its argument like this:

-lresolv -lsocket -lnsl -lintl -ldl -lrt -L /usr/pkg/lib /usr/pkg/lib/libssl.a -lm -lpython3.2

This confuses our configure.ac and subsequently causes build failure.

I'm not sure if we should consider it a bug of python-config, but the
attached patch works as a workaround.

Subtickets

Attachments (1)

configure.ac.diff (743 bytes) - added by jinmei 7 years ago.

Download all attachments as: .zip

Change History (16)

Changed 7 years ago by jinmei

comment:1 Changed 7 years ago by jelte

  • Milestone changed from Next-Sprint-Proposed to Sprint-20130219

comment:2 Changed 7 years ago by jinmei

  • Status changed from new to reviewing

trac2661 is ready for review. I've slightly updated the originally
attached patch so that it can handle multiple -L switches, more than
one space or tabs (although it wasn't necessary for the originally
reported env).

Proposed changelog:

566.?	[build]		jinmei
	The ./configure script can now handle output from python-config
	--ldflags that contains a space after -L switches.  This fixes
	failure reported on some Solaris environments.
	(Trac #2661, git TBD)

comment:3 follow-up: Changed 7 years ago by jelte

  • Owner changed from UnAssigned to jinmei

umz, on my system this removes all flags, looks like due to that -n argument to sed (build still works but I suspect that is a coincidence)

comment:4 in reply to: ↑ 3 Changed 7 years ago by jinmei

Replying to jelte:

umz, on my system this removes all flags, looks like due to that -n argument to sed (build still works but I suspect that is a coincidence)

What do you mean by "removes all flags"? It should have something like "-L/usr/local/lib"
but the new configure.ac doesn't add it to PYTHON_LDFLAGS?

comment:5 Changed 7 years ago by jinmei

  • Owner changed from jinmei to jelte

comment:6 follow-up: Changed 7 years ago by jelte

  • Owner changed from jelte to jinmei

No I mean the resulting value in $python_config_ldflags ends up being empty, while python-X-config --ldflags certainly is not;

in current master, config output shows:

  Python:        -I/usr/include/python3.2mu -I/usr/include/python3.2mu
                 
                  -L/usr/lib/python3.2/config-3.2mu  -Wl,-R/usr/lib/python3.2/config-3.2mu
                 -lpython3.2

but in this branch:

  Python:        -I/usr/include/python3.2mu -I/usr/include/python3.2mu
                 
                 -L/usr/lib  -Wl,-R/usr/lib

(also visible by adding an echo after the sed command in configure.ac)

comment:7 in reply to: ↑ 6 Changed 7 years ago by jinmei

Replying to jelte:

No I mean the resulting value in $python_config_ldflags ends up being empty, while python-X-config --ldflags certainly is not;

What's your python-X-config --ldflags output?

comment:8 Changed 7 years ago by jinmei

  • Owner changed from jinmei to jelte

comment:9 follow-up: Changed 7 years ago by jelte

  • Owner changed from jelte to jinmei

Ah, I think I finally figured it out.

My python3.2-config --ldflags output is:
-L/usr/lib/python3.2/config-3.2mu -lpthread -ldl -lutil -lm -lpython3.2mu -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions

And I have been testing several variations of sed in scripts and configure.ac; the problems here seems to be that the blockquotes don't survive (it works in raw shellscript but not in configure.ac).

If I add these lines in configure.ac (PYCONFIG added for easy grepping):

    echo "PYCONFIG command: ${PYTHON}-config --ldflags"

    P=`${PYTHON}-config --ldflags`
    echo "PYCONFIG output: '$P'"

    P=`${PYTHON}-config --ldflags | sed -ne 's/\([ \t]*-L\)[ ]*\([^ \t]*[ \t]*\)/\1\2/pg'`
    echo "PYCONFIG output after sed: '$P'"

    P=[`${PYTHON}-config --ldflags | sed -ne 's/\([ \t]*-L\)[ ]*\([^ \t]*[ \t]*\)/\1\2/pg'`]
    echo "PYCONFIG output after sed quoted: '$P'"

The output is:

PYCONFIG command: /usr/bin/python3.2-config --ldflags
PYCONFIG output: '-L/usr/lib/python3.2/config-3.2mu -lpthread -ldl -lutil -lm -lpython3.2mu -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions'
PYCONFIG output after sed: ''
PYCONFIG output after sed quoted: '-L/usr/lib/python3.2/config-3.2mu -lpthread -ldl -lutil -lm -lpython3.2mu -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions'

And, additionally, because it only prints matching lines, it would fail if my output did not happen to have an -L value.

So I suggest we quote the command, and either first make sure -L is present in the first place, or also let it replace -l[ ]*; e.g.

	python_config_ldflags=[`${PYTHON}-config --ldflags | sed -ne 's/\([ \t]*-[lL]\)[ ]*\([^ \t]*[ \t]*\)/\1\2/pg'`]

Removing spaces after -l is in principle unnecessary in itself, but at least it would always match if there is something useful in the -config output.

The only question is whether that would break with any other version of autoconf :)

comment:10 in reply to: ↑ 9 Changed 7 years ago by jinmei

Replying to jelte:

My python3.2-config --ldflags output is:
-L/usr/lib/python3.2/config-3.2mu -lpthread -ldl -lutil -lm -lpython3.2mu -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions

And I have been testing several variations of sed in scripts and configure.ac; the problems here seems to be that the blockquotes don't survive (it works in raw shellscript but not in configure.ac).

Hmm, strange...

Removing spaces after -l is in principle unnecessary in itself, but at least it would always match if there is something useful in the -config output.

The only question is whether that would break with any other version of autoconf :)

Okay, in that case I'd suggest using []. At least it doesn't cause
disruption for me either, and we can confirm it with buildbots, too.
Also, even if there's some portability issues depending on the version
of autoconf we can't check ourselves, it's less critical because
release versions are provided with pre-generated configure script.

As for the case where -L doesn't exist, we can actually ignore the
entire output because this part of the script only extracts -Lxxx
values. I clarified that with revised comments.

comment:11 Changed 7 years ago by jinmei

  • Owner changed from jinmei to jelte

comment:12 follow-up: Changed 7 years ago by jelte

  • Owner changed from jelte to jinmei

ah, ok, in that case it looks OK now, and can be merged :)

comment:13 in reply to: ↑ 12 Changed 7 years ago by jinmei

Replying to jelte:

ah, ok, in that case it looks OK now, and can be merged :)

Thanks, merge done, closing.

comment:14 Changed 7 years ago by jinmei

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:15 Changed 7 years ago by jinmei

  • Total Hours changed from 0 to 1.5
Note: See TracTickets for help on using tickets.