This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Cannot set LDFLAGS containing $
Type: compile error Stage:
Components: Build Versions: Python 3.7, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Dakon, christian.heimes
Priority: normal Keywords:

Created on 2019-02-22 16:05 by Dakon, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg336326 - (view) Author: Rolf Eike Beer (Dakon) * Date: 2019-02-22 16:05
My use case is: LDFLAGS=-Wl,-rpath,'$ORIGIN/../lib'

This works fine for everything build directly by the Makefile, but for everything that is build through the python distutils this breaks. This is not an issue of the python side, it happens because the Makefile passes the information to python using LDSHARED='$(BLDSHARED)'. At this point the variable is expanded and the $ORIGIN is expanded by the shell (or so) before passing it to python, so python actually received "-Wl,-rpath,/../lib" from the environment variable.

I have worked around locally by doing something like $(subst $$,~dollar~,$(BLDSHARED)) and replacing that inside python with \\$ or so. Really hacky, but works for my current setup.
msg337002 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-03-02 11:46
There is a simpler solution. How about you use double quotes instead of single quotes and let the shell expand the variable before you pass it down into the process? 

$ export ORIGIN=/origin
$ echo LDFLAGS=-Wl,-rpath,'$ORIGIN/../lib'
LDFLAGS=-Wl,-rpath,$ORIGIN/../lib
$ echo LDFLAGS=-Wl,-rpath,"$ORIGIN/../lib"
LDFLAGS=-Wl,-rpath,/origin/../lib
msg337010 - (view) Author: Rolf Eike Beer (Dakon) * Date: 2019-03-02 13:02
No, it's not. $ORIGIN is a special value that must be literally in the RPATH (i.e. in the ELF), so that the binary is relocatable and will looks for the libraries relative to it's location.

I wonder if I could do "export ORIGIN='$ORIGIN'" instead, so the expansions will bring back the original value again. This is only a solution for this usecase.
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80262
2019-03-02 13:02:18Dakonsetmessages: + msg337010
2019-03-02 11:46:32christian.heimessetnosy: + christian.heimes
messages: + msg337002
2019-02-22 16:05:17Dakoncreate