Index: clang/lib/Driver/ToolChains/Fuchsia.cpp =================================================================== --- clang/lib/Driver/ToolChains/Fuchsia.cpp +++ clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -125,9 +125,12 @@ CmdArgs.push_back("--push-state"); CmdArgs.push_back("--as-needed"); if (OnlyLibstdcxxStatic) - CmdArgs.push_back("-static"); + CmdArgs.push_back("-Bstatic"); ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); - CmdArgs.push_back("-lm"); + if (OnlyLibstdcxxStatic) { + CmdArgs.push_back("-Bdynamic"); + CmdArgs.push_back("-lm"); + } CmdArgs.push_back("--pop-state"); } } Index: clang/test/Driver/fuchsia.cpp =================================================================== --- clang/test/Driver/fuchsia.cpp +++ clang/test/Driver/fuchsia.cpp @@ -20,7 +20,6 @@ // CHECK: "--push-state" // CHECK: "--as-needed" // CHECK: "-lc++" -// CHECK: "-lm" // CHECK: "--pop-state" // CHECK: "[[RESOURCE_DIR]]{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}lib{{/|\\\\}}libclang_rt.builtins.a" // CHECK: "-lc" @@ -37,8 +36,9 @@ // RUN: | FileCheck %s -check-prefix=CHECK-STATIC // CHECK-STATIC: "--push-state" // CHECK-STATIC: "--as-needed" -// CHECK-STATIC: "-static" +// CHECK-STATIC: "-Bstatic" // CHECK-STATIC: "-lc++" +// CHECK-STATIC: "-Bdynamic" // CHECK-STATIC: "-lm" // CHECK-STATIC: "--pop-state" // CHECK-STATIC: "-lc"