Commit 827aab07 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/ld: don't pass -rdynamic to external linker if -static is used

Fixes #7800.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/87790051
parent 32dffef0
...@@ -654,6 +654,20 @@ hostlink(void) ...@@ -654,6 +654,20 @@ hostlink(void)
if(*p == '\0') if(*p == '\0')
break; break;
argv[argc++] = p; argv[argc++] = p;
// clang, unlike GCC, passes -rdynamic to the linker
// even when linking with -static, causing a linker
// error when using GNU ld. So take out -rdynamic if
// we added it. We do it in this order, rather than
// only adding -rdynamic later, so that -extldflags
// can override -rdynamic without using -static.
if(iself && strncmp(p, "-static", 7) == 0 && (p[7]==' ' || p[7]=='\0')) {
for(i=0; i<argc; i++) {
if(strcmp(argv[i], "-rdynamic") == 0)
argv[i] = "-static";
}
}
p = strchr(p + 1, ' '); p = strchr(p + 1, ' ');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment