Index: lib/Driver/ToolChains/FreeBSD.cpp =================================================================== --- lib/Driver/ToolChains/FreeBSD.cpp +++ lib/Driver/ToolChains/FreeBSD.cpp @@ -317,6 +317,8 @@ // When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall // back to '/usr/lib' if it doesn't exist. if ((Triple.getArch() == llvm::Triple::x86 || + Triple.getArch() == llvm::Triple::mips || + Triple.getArch() == llvm::Triple::mipsel || Triple.getArch() == llvm::Triple::ppc) && D.getVFS().exists(getDriver().SysRoot + "/usr/lib32/crt1.o")) getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32"); Index: test/Driver/freebsd.c =================================================================== --- test/Driver/freebsd.c +++ test/Driver/freebsd.c @@ -36,6 +36,12 @@ // RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32 // +// Check that O32 MIPS uses /usr/lib32 on a 64-bit tree. +// +// RUN: %clang -target mips-freebsd12 %s \ +// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s +// // Check that the new linker flags are passed to FreeBSD // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \