diff options
-rw-r--r-- | compiler/GHC/Driver/Session.hs | 7 | ||||
-rw-r--r-- | compiler/GHC/Settings.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Settings/IO.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/SysTools/Tasks.hs | 32 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | distrib/configure.ac.in | 1 | ||||
-rw-r--r-- | docs/users_guide/phases.rst | 7 | ||||
-rw-r--r-- | hadrian/bindist/Makefile | 1 | ||||
-rw-r--r-- | hadrian/cfg/system.config.in | 1 | ||||
-rw-r--r-- | hadrian/doc/user-settings.md | 1 | ||||
-rw-r--r-- | hadrian/src/Oracles/Setting.hs | 2 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 1 | ||||
-rw-r--r-- | m4/fp_settings.m4 | 3 | ||||
-rw-r--r-- | m4/fp_setup_windows_toolchain.m4 | 1 | ||||
-rw-r--r-- | mk/config.mk.in | 3 | ||||
-rw-r--r-- | rts/include/ghc.mk | 1 | ||||
-rw-r--r-- | testsuite/ghc-config/ghc-config.hs | 1 |
17 files changed, 55 insertions, 15 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index b78d141061..0af3549b7c 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -92,6 +92,7 @@ module GHC.Driver.Session ( sPgm_P, sPgm_F, sPgm_c, + sPgm_cxx, sPgm_a, sPgm_l, sPgm_lm, @@ -130,7 +131,7 @@ module GHC.Driver.Session ( ghcUsagePath, ghciUsagePath, topDir, versionedAppDir, versionedFilePath, extraGccViaCFlags, globalPackageDatabasePath, - pgm_L, pgm_P, pgm_F, pgm_c, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, + pgm_L, pgm_P, pgm_F, pgm_c, pgm_cxx, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, pgm_windres, pgm_ar, pgm_otool, pgm_install_name_tool, pgm_ranlib, pgm_lo, pgm_lc, pgm_lcc, pgm_i, opt_L, opt_P, opt_F, opt_c, opt_cxx, opt_a, opt_l, opt_lm, opt_i, @@ -823,6 +824,8 @@ pgm_F :: DynFlags -> String pgm_F dflags = toolSettings_pgm_F $ toolSettings dflags pgm_c :: DynFlags -> String pgm_c dflags = toolSettings_pgm_c $ toolSettings dflags +pgm_cxx :: DynFlags -> String +pgm_cxx dflags = toolSettings_pgm_cxx $ toolSettings dflags pgm_a :: DynFlags -> (String,[Option]) pgm_a dflags = toolSettings_pgm_a $ toolSettings dflags pgm_l :: DynFlags -> (String,[Option]) @@ -2163,6 +2166,8 @@ dynamic_flags_deps = [ $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_F = f } , make_ord_flag defFlag "pgmc" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_c = f } + , make_ord_flag defFlag "pgmcxx" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_cxx = f } , (Deprecated, defFlag "pgmc-supports-no-pie" $ noArgM $ \d -> do deprecate $ "use -pgml-supports-no-pie instead" diff --git a/compiler/GHC/Settings.hs b/compiler/GHC/Settings.hs index e6226696dc..5f1d97b01d 100644 --- a/compiler/GHC/Settings.hs +++ b/compiler/GHC/Settings.hs @@ -28,6 +28,7 @@ module GHC.Settings , sPgm_P , sPgm_F , sPgm_c + , sPgm_cxx , sPgm_a , sPgm_l , sPgm_lm @@ -98,6 +99,7 @@ data ToolSettings = ToolSettings , toolSettings_pgm_P :: (String, [Option]) , toolSettings_pgm_F :: String , toolSettings_pgm_c :: String + , toolSettings_pgm_cxx :: String , toolSettings_pgm_a :: (String, [Option]) , toolSettings_pgm_l :: (String, [Option]) , toolSettings_pgm_lm :: Maybe (String, [Option]) @@ -208,6 +210,8 @@ sPgm_F :: Settings -> String sPgm_F = toolSettings_pgm_F . sToolSettings sPgm_c :: Settings -> String sPgm_c = toolSettings_pgm_c . sToolSettings +sPgm_cxx :: Settings -> String +sPgm_cxx = toolSettings_pgm_cxx . sToolSettings sPgm_a :: Settings -> (String, [Option]) sPgm_a = toolSettings_pgm_a . sToolSettings sPgm_l :: Settings -> (String, [Option]) diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs index 308c5447e1..136607df27 100644 --- a/compiler/GHC/Settings/IO.hs +++ b/compiler/GHC/Settings/IO.hs @@ -78,6 +78,7 @@ initSettings top_dir = do targetPlatformString <- getSetting "target platform string" myExtraGccViaCFlags <- getSetting "GCC extra via C opts" cc_prog <- getToolSetting "C compiler command" + cxx_prog <- getToolSetting "C++ compiler command" cc_args_str <- getSetting "C compiler flags" cxx_args_str <- getSetting "C++ compiler flags" gccSupportsNoPie <- getBooleanSetting "C compiler supports -no-pie" @@ -173,6 +174,7 @@ initSettings top_dir = do , toolSettings_pgm_P = (cpp_prog, cpp_args) , toolSettings_pgm_F = "" , toolSettings_pgm_c = cc_prog + , toolSettings_pgm_cxx = cxx_prog , toolSettings_pgm_a = (as_prog, as_args) , toolSettings_pgm_l = (ld_prog, ld_args) , toolSettings_pgm_lm = ld_r diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs index 9b4400903e..ce741e2c1a 100644 --- a/compiler/GHC/SysTools/Tasks.hs +++ b/compiler/GHC/SysTools/Tasks.hs @@ -81,13 +81,13 @@ runPp logger dflags args = traceToolCommand logger "pp" $ do -- | Run compiler of C-like languages and raw objects (such as gcc or clang). runCc :: Maybe ForeignSrcLang -> Logger -> TmpFs -> DynFlags -> [Option] -> IO () runCc mLanguage logger tmpfs dflags args = traceToolCommand logger "cc" $ do - let p = pgm_c dflags - args1 = map Option userOpts + let args1 = map Option userOpts args2 = languageOptions ++ args ++ args1 -- We take care to pass -optc flags in args1 last to ensure that the -- user can override flags passed by GHC. See #14452. mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags cc_filter "C Compiler" p args2 mb_env + runSomethingResponseFile logger tmpfs dflags cc_filter dbgstring prog args2 + mb_env where -- discard some harmless warnings from gcc that we can't turn off cc_filter = unlines . doFilter . lines @@ -143,17 +143,23 @@ runCc mLanguage logger tmpfs dflags args = traceToolCommand logger "cc" $ do -- compiling .hc files, by adding the -x c option. -- Also useful for plain .c files, just in case GHC saw a -- -x c option. - (languageOptions, userOpts) = case mLanguage of - Nothing -> ([], userOpts_c) - Just language -> ([Option "-x", Option languageName], opts) + (languageOptions, userOpts, prog, dbgstring) = case mLanguage of + Nothing -> ([], userOpts_c, pgm_c dflags, "C Compiler") + Just language -> ([Option "-x", Option languageName], opts, prog, dbgstr) where - (languageName, opts) = case language of - LangC -> ("c", userOpts_c) - LangCxx -> ("c++", userOpts_cxx) - LangObjc -> ("objective-c", userOpts_c) - LangObjcxx -> ("objective-c++", userOpts_cxx) - LangAsm -> ("assembler", []) - RawObject -> ("c", []) -- claim C for lack of a better idea + (languageName, opts, prog, dbgstr) = case language of + LangC -> ("c", userOpts_c + ,pgm_c dflags, "C Compiler") + LangCxx -> ("c++", userOpts_cxx + ,pgm_cxx dflags , "C++ Compiler") + LangObjc -> ("objective-c", userOpts_c + ,pgm_c dflags , "Objective C Compiler") + LangObjcxx -> ("objective-c++", userOpts_cxx + ,pgm_cxx dflags, "Objective C++ Compiler") + LangAsm -> ("assembler", [] + ,pgm_c dflags, "Asm Compiler") + RawObject -> ("c", [] + ,pgm_c dflags, "C Compiler") -- claim C for lack of a better idea userOpts_c = getOpts dflags opt_c userOpts_cxx = getOpts dflags opt_cxx diff --git a/configure.ac b/configure.ac index 6456721d2b..f9e64c3383 100644 --- a/configure.ac +++ b/configure.ac @@ -354,6 +354,7 @@ else # are screwed up. Configure doesn't think they're ever equal and # so never tried without the prefix. AC_PATH_PROG([CC],[gcc], [clang]) + AC_PATH_PROG([CXX],[g++], [clang++]) AC_PATH_PROG([NM],[nm]) AC_PATH_PROG([LD],[ld]) AC_PATH_PROG([AR],[ar]) @@ -472,6 +473,7 @@ AC_ARG_WITH([clang], dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set), dnl later CC is copied to CC_STAGE{1,2,3} AC_PROG_CC([cc gcc clang]) +AC_PROG_CXX([g++ clang++ c++]) MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0]) diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in index d5b99cbb8a..07e0687a9d 100644 --- a/distrib/configure.ac.in +++ b/distrib/configure.ac.in @@ -92,6 +92,7 @@ AC_ARG_ENABLE(distro-toolchain, dnl ** Which gcc to use? dnl -------------------------------------------------------------- AC_PROG_CC([gcc clang]) +AC_PROG_CXX([g++ clang++ c++]) dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`) AC_PROG_CPP diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst index 54ed63a06c..b784fa7662 100644 --- a/docs/users_guide/phases.rst +++ b/docs/users_guide/phases.rst @@ -38,6 +38,13 @@ given compilation phase: Use ⟨cmd⟩ as the C compiler. +.. ghc-flag:: -pgmcxx ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the C++ compiler + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the C++ compiler. + .. ghc-flag:: -pgmlo ⟨cmd⟩ :shortdesc: Use ⟨cmd⟩ as the LLVM optimiser :type: dynamic diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile index dbed7a0502..6b2e1f8754 100644 --- a/hadrian/bindist/Makefile +++ b/hadrian/bindist/Makefile @@ -105,6 +105,7 @@ lib/settings : @echo '[("GCC extra via C opts", "$(GccExtraViaCOpts)")' >> $@ @echo ',("C compiler command", "$(SettingsCCompilerCommand)")' >> $@ @echo ',("C compiler flags", "$(SettingsCCompilerFlags)")' >> $@ + @echo ',("C++ compiler command", "$(SettingsCxxCompilerCommand)")' >> $@ @echo ',("C++ compiler flags", "$(SettingsCxxCompilerFlags)")' >> $@ @echo ',("C compiler link flags", "$(SettingsCCompilerLinkFlags)")' >> $@ @echo ',("C compiler supports -no-pie", "$(SettingsCCompilerSupportsNoPie)")' >> $@ diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in index ae70823202..385279a435 100644 --- a/hadrian/cfg/system.config.in +++ b/hadrian/cfg/system.config.in @@ -142,6 +142,7 @@ ld-is-gnu-ld = @LdIsGNULd@ ar-args = @ArArgs@ settings-c-compiler-command = @SettingsCCompilerCommand@ +settings-cxx-compiler-command = @SettingsCxxCompilerCommand@ settings-haskell-cpp-command = @SettingsHaskellCPPCommand@ settings-haskell-cpp-flags = @SettingsHaskellCPPFlags@ settings-c-compiler-flags = @SettingsCCompilerFlags@ diff --git a/hadrian/doc/user-settings.md b/hadrian/doc/user-settings.md index 82f9964ac6..7b304ec0f3 100644 --- a/hadrian/doc/user-settings.md +++ b/hadrian/doc/user-settings.md @@ -369,6 +369,7 @@ the right names for them: argument for `hadrian/ghci` to work * `cc` refers to C compiler commands + * `cxx` refers to C++ compiler commands * `c.opts` for commands that call the C compiler on some C files * `deps.opts` for commands that call the C compiler for figuring out diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs index 6ce01327c5..62a1ebcd67 100644 --- a/hadrian/src/Oracles/Setting.hs +++ b/hadrian/src/Oracles/Setting.hs @@ -106,6 +106,7 @@ data SettingList = ConfCcArgs Stage -- Eventually much of that local can probably be computed just in Hadrian. data SettingsFileSetting = SettingsFileSetting_CCompilerCommand + | SettingsFileSetting_CxxCompilerCommand | SettingsFileSetting_HaskellCPPCommand | SettingsFileSetting_HaskellCPPFlags | SettingsFileSetting_CCompilerFlags @@ -198,6 +199,7 @@ settingList key = fmap words $ lookupSystemConfig $ case key of settingsFileSetting :: SettingsFileSetting -> Action String settingsFileSetting key = lookupSystemConfig $ case key of SettingsFileSetting_CCompilerCommand -> "settings-c-compiler-command" + SettingsFileSetting_CxxCompilerCommand -> "settings-cxx-compiler-command" SettingsFileSetting_HaskellCPPCommand -> "settings-haskell-cpp-command" SettingsFileSetting_HaskellCPPFlags -> "settings-haskell-cpp-flags" SettingsFileSetting_CCompilerFlags -> "settings-c-compiler-flags" diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index 5653bd1d25..1cd95d7961 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -298,6 +298,7 @@ generateSettings = do [ ("GCC extra via C opts", expr $ lookupSystemConfig "gcc-extra-via-c-opts") , ("C compiler command", expr $ settingsFileSetting SettingsFileSetting_CCompilerCommand) , ("C compiler flags", expr $ settingsFileSetting SettingsFileSetting_CCompilerFlags) + , ("C++ compiler command", expr $ settingsFileSetting SettingsFileSetting_CxxCompilerCommand) , ("C++ compiler flags", expr $ settingsFileSetting SettingsFileSetting_CxxCompilerFlags) , ("C compiler link flags", expr $ settingsFileSetting SettingsFileSetting_CCompilerLinkFlags) , ("C compiler supports -no-pie", expr $ settingsFileSetting SettingsFileSetting_CCompilerSupportsNoPie) diff --git a/m4/fp_settings.m4 b/m4/fp_settings.m4 index dbacd3a816..0b75cf8d35 100644 --- a/m4/fp_settings.m4 +++ b/m4/fp_settings.m4 @@ -11,6 +11,7 @@ AC_DEFUN([FP_SETTINGS], mingw_bin_prefix='$$tooldir/mingw/bin/' SettingsCCompilerCommand="${mingw_bin_prefix}clang.exe" SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2" + SettingsCxxCompilerCommand="${mingw_bin_prefix}clang++.exe" SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2" SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2" SettingsHaskellCPPCommand="${mingw_bin_prefix}clang.exe" @@ -32,6 +33,7 @@ AC_DEFUN([FP_SETTINGS], SettingsCCompilerCommand="$CC" SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2" + SettingsCxxCompilerCommand="$CXX" SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2" SettingsHaskellCPPCommand="$HaskellCPPCmd" SettingsHaskellCPPFlags="$HaskellCPPArgs" @@ -104,6 +106,7 @@ AC_DEFUN([FP_SETTINGS], SettingsCCompilerSupportsNoPie="$CONF_GCC_SUPPORTS_NO_PIE" AC_SUBST(SettingsCCompilerCommand) + AC_SUBST(SettingsCxxCompilerCommand) AC_SUBST(SettingsHaskellCPPCommand) AC_SUBST(SettingsHaskellCPPFlags) AC_SUBST(SettingsCCompilerFlags) diff --git a/m4/fp_setup_windows_toolchain.m4 b/m4/fp_setup_windows_toolchain.m4 index 35e322c8a0..79a6ac6531 100644 --- a/m4/fp_setup_windows_toolchain.m4 +++ b/m4/fp_setup_windows_toolchain.m4 @@ -80,6 +80,7 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[ mingwbin="$hardtop/inplace/mingw/bin/" CC="${mingwbin}clang.exe" + CXX="${mingwbin}clang++.exe" cflags="--rtlib=compiler-rt" CFLAGS="$cflags" CONF_CC_OPTS_STAGE1="$cflags" diff --git a/mk/config.mk.in b/mk/config.mk.in index 10ba35b79b..fdbaab58b9 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -358,7 +358,7 @@ BIN_DIST_TAR_COMP = $(BIN_DIST_NAME)-$(TARGETPLATFORM).tar.$(TAR_COMP_EXT) # SRC_HC_OPTS is *not* for adding flags that are required to make your # build work. Examples: # -# - instead of using -pgmc/-pgma-/-pgml, use the --with-gcc option to configure +# - instead of using -pgmc/-pgmcxx/-pgma-/-pgml, use the --with-gcc option to configure # # - if you need -optc, -opta, or -optl flags, the CONF_CC_* and CONF_LD_* # variables are more appropriate (set via configure) @@ -457,6 +457,7 @@ TargetHasLibm = @TargetHasLibm@ TablesNextToCode = @TablesNextToCode@ SettingsCCompilerCommand = @SettingsCCompilerCommand@ +SettingsCxxCompilerCommand = @SettingsCxxCompilerCommand@ SettingsHaskellCPPCommand = @SettingsHaskellCPPCommand@ SettingsHaskellCPPFlags = @SettingsHaskellCPPFlags@ SettingsCCompilerFlags = @SettingsCCompilerFlags@ diff --git a/rts/include/ghc.mk b/rts/include/ghc.mk index b8b74f4a89..92a70538d1 100644 --- a/rts/include/ghc.mk +++ b/rts/include/ghc.mk @@ -193,6 +193,7 @@ $(includes_SETTINGS) : rts/include/Makefile | $$(dir $$@)/. @echo '[("GCC extra via C opts", "$(GccExtraViaCOpts)")' >> $@ @echo ',("C compiler command", "$(SettingsCCompilerCommand)")' >> $@ @echo ',("C compiler flags", "$(SettingsCCompilerFlags)")' >> $@ + @echo ',("C++ compiler command", "$(SettingsCxxCompilerCommand)")' >> $@ @echo ',("C++ compiler flags", "$(SettingsCxxCompilerFlags)")' >> $@ @echo ',("C compiler link flags", "$(SettingsCCompilerLinkFlags)")' >> $@ @echo ',("C compiler supports -no-pie", "$(SettingsCCompilerSupportsNoPie)")' >> $@ diff --git a/testsuite/ghc-config/ghc-config.hs b/testsuite/ghc-config/ghc-config.hs index efb88f81f2..b38401b433 100644 --- a/testsuite/ghc-config/ghc-config.hs +++ b/testsuite/ghc-config/ghc-config.hs @@ -35,6 +35,7 @@ main = do getGhcFieldProgWithDefault fields "LLC" "LLVM llc command" "llc" getGhcFieldProgWithDefault fields "TEST_CC" "C compiler command" "gcc" getGhcFieldProgWithDefault fields "TEST_CC_OPTS" "C compiler flags" "" + getGhcFieldProgWithDefault fields "TEST_CXX" "C++ compiler command" "g++" getGhcFieldOrFail :: [(String,String)] -> String -> String -> IO () getGhcFieldOrFail fields mkvar key |