Have cosmo_dlopen() request -z execstack on Linux

The AMD HIP SDK for Linux ships prebuilt DSOs with an RWX PT_GNU_STACK
since old versions of GCC made it nearly impossible to build artifacts
where that wasn't the case, however modern glibc systems will flat out
refuse to link RWX DSOs from an execuatble that uses PT_GNU_STACK = RW
This commit is contained in:
Justine Tunney 2024-01-07 11:37:18 -08:00
parent 531ac85923
commit 5ae2554c10
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -618,7 +618,15 @@ static dontinline bool foreign_compile(char exe[hasatleast PATH_MAX]) {
}
int pid, ws;
char *args[] = {
"cc", "-pie", "-fPIC", src, "-o", tmp, IsNetbsd() ? 0 : "-ldl", 0,
"cc",
"-pie",
"-fPIC",
src,
"-o",
tmp,
IsLinux() ? "-Wl,-z,execstack" : "-DIGNORE",
IsNetbsd() ? 0 : "-ldl",
0,
};
errno_t err = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
if (err) {