u***@aetey.se
2014-08-25 06:51:28 UTC
Hello,
The dynamic loader path is currently being hardwired into the pcc executable.
I find this too restrictive, runtime configurability of the path is
sometimes important. I suggest a patch like the following (a more general
solution for configurability would be probably better but this patch is
sufficent for my purposes) :
--- cc/cc/cc.c.ori 2014-08-24 21:03:38.420292533 +0200
+++ cc/cc/cc.c 2014-08-24 21:17:43.274929318 +0200
@@ -995,6 +995,9 @@
/*
* Linker
*/
+ if (dynlinker[0] && dynlinker[1]) /* there is some default */
+ if ((t=getenv("PCC_DYNAMIC_LINKER"))) /* we want to change it */
+ dynlinker[1] = t;
setup_ld_flags();
if (run_linker())
exandrm(0);
This may result in some dead code if dynlinker is not set to be present
but does not lead to a crash (the dead code is possibly optimized away?
this can otherwise be done differently, via macros).
Of course, a corresponding description should be added in the documentation.
------- some background:
In general, I see hardwiring the dynamic loader path into the produced
executables as a bad design. "Properly used" executables (started by a
runtime loader explicitly) do not need this so the configurability of the
unused string is not an issue per se. I could let pcc always hardwire
"/:-b" :)
Unfortunately there are too many scripts which assume that a freshly
compiled executable is runnable "as-is" even if it is dynamically
linked. Hardwiring in the executable a path to the loader (which
happens to be available at that path at the moment) helps to satisfy
these oversimplified assumptions.
(Such scripts otherwise usually have to go out of their way to add
LD_LIBRARY_PATH or other means to find the needed shared libraries, they
could exactly as well add an explicit runtime loader to the command -
but unfortunately they often do not).
Regards,
Rune
The dynamic loader path is currently being hardwired into the pcc executable.
I find this too restrictive, runtime configurability of the path is
sometimes important. I suggest a patch like the following (a more general
solution for configurability would be probably better but this patch is
sufficent for my purposes) :
--- cc/cc/cc.c.ori 2014-08-24 21:03:38.420292533 +0200
+++ cc/cc/cc.c 2014-08-24 21:17:43.274929318 +0200
@@ -995,6 +995,9 @@
/*
* Linker
*/
+ if (dynlinker[0] && dynlinker[1]) /* there is some default */
+ if ((t=getenv("PCC_DYNAMIC_LINKER"))) /* we want to change it */
+ dynlinker[1] = t;
setup_ld_flags();
if (run_linker())
exandrm(0);
This may result in some dead code if dynlinker is not set to be present
but does not lead to a crash (the dead code is possibly optimized away?
this can otherwise be done differently, via macros).
Of course, a corresponding description should be added in the documentation.
------- some background:
In general, I see hardwiring the dynamic loader path into the produced
executables as a bad design. "Properly used" executables (started by a
runtime loader explicitly) do not need this so the configurability of the
unused string is not an issue per se. I could let pcc always hardwire
"/:-b" :)
Unfortunately there are too many scripts which assume that a freshly
compiled executable is runnable "as-is" even if it is dynamically
linked. Hardwiring in the executable a path to the loader (which
happens to be available at that path at the moment) helps to satisfy
these oversimplified assumptions.
(Such scripts otherwise usually have to go out of their way to add
LD_LIBRARY_PATH or other means to find the needed shared libraries, they
could exactly as well add an explicit runtime loader to the command -
but unfortunately they often do not).
Regards,
Rune