Skip to content

Commit c8a8723

Browse files
committed
build: PIC-ify the dynamic SDK overlay
The dynamic SDK overlay needs to be built with -fPIC. Ensure that the clang importer is marking the external globals appropriately. This was caught by building the swiftGlibc SDK overlay component in a dynamic configuration. Failure to do so will create RIP-relative references on x86_64 which may overflow at runtime.
1 parent 53be298 commit c8a8723

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
439439
SHIMS_INCLUDE_FLAG, searchPathOpts.RuntimeResourcePath,
440440
});
441441

442+
// Enable Position Independence. `-fPIC` is not supported on Windows, which
443+
// is implicitly position independent.
444+
if (!triple.isOSWindows())
445+
invocationArgStrs.insert(invocationArgStrs.end(), {"-fPIC"});
446+
442447
// Enable modules.
443448
invocationArgStrs.insert(invocationArgStrs.end(), {
444449
"-fmodules",

0 commit comments

Comments
 (0)