Commit b831dfa
authored
fix(platform): give Linux the rpaths macOS already gets (#120) --skip-tests
A program built on Linux does not start:
./main: error while loading shared libraries: libphpx.so:
cannot open shared object file: No such file or directory
libphpx.so sits beside the phpx checkout and libphp.so under the prefix the
libphp installer chose. The link line names both with -L, which tells the
linker where to look and the loader nothing, and neither directory is on the
default search path. The binary carries no RPATH or RUNPATH at all, so it
only runs under LD_LIBRARY_PATH.
Every part of the mechanism is already present and already reached on Linux.
NativeCommandOptionsTrait asks the platform for getDefaultRpaths() on every
non-nano build, and GccLikeBackend emits -Wl,-rpath for each entry it gets
back. Only the list is missing: PlatformBase returns an empty one, Macos
overrides it with the phpx and PHP library directories, and Linux never
overrode anything.
Move that override up to UnixPlatform, where Linux inherits it. The two
directories are the same ones the -L flags already name, each still guarded
by is_dir(), so macOS keeps the behavior it has today.
Android and Ios return an empty list on purpose: a path on the build host
means nothing on the device that runs the output. Wasi is a cross target too
and had been relying on the inherited default, so it states the same thing
explicitly rather than acquiring host paths from this move.
The recorded paths are absolute, matching what macOS has always emitted. That
is enough to run where the program was built, which is what an embed build
against a private PHP prefix can do in any case. Relocatable output needs
$ORIGIN and the libraries shipped alongside, or --full-static, and neither is
decided here.1 parent 69daefa commit b831dfa
3 files changed
Lines changed: 39 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | 79 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
169 | 199 | | |
170 | 200 | | |
171 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
26 | 35 | | |
27 | 36 | | |
28 | 37 | | |
| |||
0 commit comments