Ticket #53605: patch-use-libcxx.3.diff

File patch-use-libcxx.3.diff, 3.0 KB (added by RJVB (René Bertin), 7 years ago)
  • incpath.c

    old new  
    129129  int relocated = cpp_relocated ();
    130130  size_t len;
    131131
     132  if (cxx_stdinc)
     133    {
     134      if (!getenv("LIBCPP_INCLUDE_PATH"))
     135        {
     136          add_path (xstrdup ("@LLVMHEADERPATH@"), SYSTEM, true, false);
     137        }
     138    }
    132139  if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0)
    133140    {
    134141      /* Look for directories that start with the standard prefix.
     
    474481  /* CPATH and language-dependent environment variables may add to the
    475482     include chain.  */
    476483  add_env_var_paths ("CPATH", BRACKET);
     484  if (stdinc && cxx_stdinc)
     485    add_env_var_paths ("LIBCPP_INCLUDE_PATH", SYSTEM);
    477486  add_env_var_paths (lang_env_vars[idx], SYSTEM);
    478487
    479488  target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
  • g++spec.c

    old new  
    4646#endif
    4747
    4848#ifndef LIBSTDCXX
    49 #define LIBSTDCXX "stdc++"
     49#define LIBSTDCXX "c++"
     50#define LIBSTDCXXABI "c++abi"
     51// using libsupc++ is a hack, probably to be dropped on systems that have a new enough libc++
     52// which has `operator delete(void*, unsigned long)`
     53#define LIBSUPCXX "supc++"
     54#else
     55#warning "LIBSTDCXX predefined"
    5056#endif
    51 #ifndef LIBSTDCXX_PROFILE
     57#undef LIBSTDCXX_PROFILE
    5258#define LIBSTDCXX_PROFILE LIBSTDCXX
    53 #endif
     59
    5460#ifndef LIBSTDCXX_STATIC
    5561#define LIBSTDCXX_STATIC NULL
     62#else
     63#warning "LIBSTDCXX_STATIC predefined"
    5664#endif
    5765
    5866void
     
    342350          j++;
    343351        }
    344352#endif
    345       generate_option (OPT_l,
    346                        saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX, 1,
    347                        CL_DRIVER, &new_decoded_options[j]);
    348       added_libraries++;
    349       j++;
    350       /* Add target-dependent static library, if necessary.  */
    351       if ((static_link || library > 1) && LIBSTDCXX_STATIC != NULL)
     353    // NOT checking for the existence of LIBSTDCXXABI and LIBSUPCXX on purpose
     354         if (getenv ("GCC_FORCE_LIBSTDCPP")) {
     355                 fprintf(stderr, "GCC_FORCE_LIBSTDCPP - using -lstdc++ instead of -l%s -l%s -l%s\n",
     356                 LIBSTDCXX, LIBSTDCXXABI, LIBSUPCXX);
     357                 generate_option (OPT_l, "stdc++", 1,
     358                                  CL_DRIVER, &new_decoded_options[j]);
     359                 added_libraries++;
     360                 j++;
     361         } else {
     362                 generate_option (OPT_l,
     363                                  saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX, 1,
     364                                  CL_DRIVER, &new_decoded_options[j]);
     365                 added_libraries++;
     366                 j++;
     367                 // add -lc++abi and -lsupc++
     368                 generate_option (OPT_l, LIBSTDCXXABI, 1,
     369                                  CL_DRIVER, &new_decoded_options[j]);
     370                 added_libraries++;
     371                 j++;
     372                 generate_option (OPT_l, LIBSUPCXX, 1,
     373                                  CL_DRIVER, &new_decoded_options[j]);
     374                 added_libraries++;
     375                 j++;
     376         }
     377         /* Add target-dependent static library, if necessary.  */
     378         if ((static_link || library > 1) && (LIBSTDCXX_STATIC != NULL || getenv("GCC_IS_BUILDING_ITSELF")))
    352379        {
    353           generate_option (OPT_l, LIBSTDCXX_STATIC, 1,
     380          generate_option (OPT_l, LIBSTDCXX_STATIC ? LIBSTDCXX_STATIC : "stdc++", 1,
    354381                           CL_DRIVER, &new_decoded_options[j]);
    355382          added_libraries++;
    356383          j++;