Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -3319,8 +3319,12 @@ if (SanArgs.linkCXXRuntimes()) StaticRuntimes.push_back("ubsan_standalone_cxx"); } - if (SanArgs.needsSafeStackRt()) - StaticRuntimes.push_back("safestack"); + if (SanArgs.needsSafeStackRt()) { + if (Args.hasFlag(options::OPT_mseparate_stack_seg, options::OPT_mno_separate_stack_seg, false)) + StaticRuntimes.push_back("safestacksepseg"); + else + StaticRuntimes.push_back("safestack"); + } if (SanArgs.needsCfiRt()) StaticRuntimes.push_back("cfi"); if (SanArgs.needsCfiDiagRt()) {