Index: lib/Driver/UniversalDriver.cpp =================================================================== --- lib/Driver/UniversalDriver.cpp +++ lib/Driver/UniversalDriver.cpp @@ -89,13 +89,7 @@ .Case("lld-link", Flavor::win_link) .Case("darwin", Flavor::darwin_ld) .Case("core", Flavor::core) -#if __APPLE__ - // On a Darwin systems, if linker binary is named "ld", use Darwin driver. - .Case("ld", Flavor::darwin_ld) -#else - // On other *nix systems, if linker binary is named "ld", use gnu driver. .Case("ld", Flavor::gnu_ld) -#endif .Default(Flavor::invalid); } @@ -160,6 +154,12 @@ Flavor flavor; +#if __APPLE__ + // On a Darwin systems, if linker binary is named "ld", use Darwin driver. + if (llvm::sys::path::filename(argv[0]).equals("ld")) { + flavor = Flavor::darwin_ld; + } else +#endif if (parsedArgs->getLastArg(OPT_core)) { flavor = Flavor::core; argv++;