@@ -120,6 +120,9 @@ static const char GCC_OPT_D_CLANG_PATCHLEVEL[] = "-D__clang_patchlevel__=0";
120120
121121static const char GCC_OPT_F_STACK_PROTECTOR [] = "-fstack-protector" ;
122122
123+ static const char GCC_OPT_NODEFAULTLIBS [] = "-nodefaultlibs" ;
124+ static const char GCC_OPT_NOSTDLIB [] = "-nostdlib" ;
125+
123126static const char CLANG_OPT_OZ [] = "-Oz" ;
124127static const char CLANG_OPT_ICF [] = "--icf" ;
125128static const char CLANG_OPT_TARGET [] = "--target" ;
@@ -713,6 +716,7 @@ int main(int argc, char* argv[], char* envp[]) {
713716 int wants_nz = 0 ;
714717 int wants_neon = 0 ;
715718
719+ int nodefaultlibs = 0 ;
716720 int address_sanitizer = 0 ;
717721 int stack_protector = 0 ;
718722 int version = 0 ;
@@ -878,6 +882,8 @@ int main(int argc, char* argv[], char* envp[]) {
878882 version = 1 ;
879883 } else if (strcmp (cur , GCC_OPT_V ) == 0 ) {
880884 verbose = 1 ;
885+ } else if (strcmp (cur , GCC_OPT_NODEFAULTLIBS ) == 0 || strcmp (cur , GCC_OPT_NOSTDLIB ) == 0 ) {
886+ nodefaultlibs = 1 ;
881887 } else if (strcmp (cur , GCC_OPT_L_STDCXX ) == 0 ) {
882888 wants_libcxx = 1 ;
883889 } else if (strcmp (cur , GCC_OPT_STATIC_LIBCXX ) == 0 ) {
@@ -1159,7 +1165,7 @@ int main(int argc, char* argv[], char* envp[]) {
11591165 Additionally, we expose these functions in the standard library headers
11601166 (math.h and complex.h) so that anyone can use them.
11611167 */
1162- if (wants_libcxx || wants_libm ) {
1168+ if (( wants_libcxx || wants_libm ) && ! nodefaultlibs ) {
11631169 kargv [kargc ++ ] = (char * ) GCC_OPT_L ;
11641170 kargv [kargc ++ ] = (char * ) PINO_MATH_LIBRARY ;
11651171 }
@@ -1396,7 +1402,7 @@ int main(int argc, char* argv[], char* envp[]) {
13961402 The NDK provided a pseudo-implementation for this as an inline, and we moved it to its
13971403 own external library.
13981404 */
1399- if (wants_libpino_mman ) {
1405+ if (wants_libpino_mman && ! nodefaultlibs ) {
14001406 kargv [kargc ++ ] = (char * ) GCC_OPT_L ;
14011407 kargv [kargc ++ ] = (char * ) PINO_MMAN_LIBRARY ;
14021408 }
0 commit comments