diff options
author | Pepe Iborra <pepeiborra@gmail.com> | 2020-09-15 07:42:18 +0100 |
---|---|---|
committer | GHC GitLab CI <ghc-ci@gitlab-haskell.org> | 2020-11-24 01:17:25 +0000 |
commit | 2ce2a5b444069ea0dc0afb483634f4ba405437cb (patch) | |
tree | ea44227e0ee6c42eafc3fbbf9ef5428299a1df39 | |
parent | 8edf564362e37c9740a351f1d71f2fa5e042f7b1 (diff) | |
download | haskell-2ce2a5b444069ea0dc0afb483634f4ba405437cb.tar.gz |
Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"
This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.
-rw-r--r-- | compiler/main/DriverPipeline.hs | 16 | ||||
-rw-r--r-- | testsuite/tests/driver/T16737.hs | 32 | ||||
-rw-r--r-- | testsuite/tests/driver/T16737.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/driver/T16737include/T16737.h | 7 | ||||
-rw-r--r-- | testsuite/tests/driver/all.T | 4 |
5 files changed, 4 insertions, 57 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index bf79ea5d02..366de193c7 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1193,6 +1193,9 @@ runPhase (RealPhase Cmm) input_fn dflags ----------------------------------------------------------------------------- -- Cc phase +-- we don't support preprocessing .c files (with -E) now. Doing so introduces +-- way too many hacks, and I can't say I've ever used it anyway. + runPhase (RealPhase cc_phase) input_fn dflags | any (cc_phase `eqPhase`) [Cc, Ccxx, HCc, Cobjc, Cobjcxx] = do @@ -1214,16 +1217,6 @@ runPhase (RealPhase cc_phase) input_fn dflags (includePathsQuote cmdline_include_paths) let include_paths = include_paths_quote ++ include_paths_global - -- pass -D or -optP to preprocessor when compiling foreign C files - -- (#16737). Doing it in this way is simpler and also enable the C - -- compiler to performs preprocessing and parsing in a single pass, - -- but it may introduce inconsistency if a different pgm_P is specified. - let more_preprocessor_opts = concat - [ ["-Xpreprocessor", i] - | not hcc - , i <- getOpts dflags opt_P - ] - let gcc_extra_viac_flags = extraGccViaCFlags dflags let pic_c_flags = picCCOpts dflags @@ -1233,7 +1226,7 @@ runPhase (RealPhase cc_phase) input_fn dflags -- hc code doesn't not #include any header files anyway, so these -- options aren't necessary. pkg_extra_cc_opts <- liftIO $ - if hcc + if cc_phase `eqPhase` HCc then return [] else getPackageExtraCcOpts dflags pkgs @@ -1324,7 +1317,6 @@ runPhase (RealPhase cc_phase) input_fn dflags ++ [ "-include", ghcVersionH ] ++ framework_paths ++ include_paths - ++ more_preprocessor_opts ++ pkg_extra_cc_opts )) diff --git a/testsuite/tests/driver/T16737.hs b/testsuite/tests/driver/T16737.hs deleted file mode 100644 index 0abe5457b0..0000000000 --- a/testsuite/tests/driver/T16737.hs +++ /dev/null @@ -1,32 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -DFOO=2 -optP=-DBAR=3 -optc=-DBAZ=5 #-} - -import Language.Haskell.TH.Syntax - -do - let code = unlines - [ "#if defined(__cplusplus)" - , "extern \"C\" {" - , "#endif" - , "#include <T16737.h>" - , "int FUN(void) {" - , " return FOO * BAR * BAZ;" - , "}" - , "#if defined(__cplusplus)" - , "}" - , "#endif" - ] - addForeignSource LangC code - addForeignSource LangCxx code - pure [] - -foreign import ccall unsafe "c_value" - c_value :: IO Int - -foreign import ccall unsafe "cxx_value" - cxx_value :: IO Int - -main :: IO () -main = do - print =<< c_value - print =<< cxx_value diff --git a/testsuite/tests/driver/T16737.stdout b/testsuite/tests/driver/T16737.stdout deleted file mode 100644 index 285b16f691..0000000000 --- a/testsuite/tests/driver/T16737.stdout +++ /dev/null @@ -1,2 +0,0 @@ -30 -30 diff --git a/testsuite/tests/driver/T16737include/T16737.h b/testsuite/tests/driver/T16737include/T16737.h deleted file mode 100644 index 08c7ca8729..0000000000 --- a/testsuite/tests/driver/T16737include/T16737.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#if defined(__cplusplus) -#define FUN cxx_value -#else -#define FUN c_value -#endif diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 668d609747..02eeeb321b 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -287,7 +287,3 @@ test('inline-check', omit_ways(['hpc', 'profasm']) test('T14452', [], run_command, ['$MAKE -s --no-print-directory T14452']) test('T15396', normal, compile_and_run, ['-package ghc']) -test('T16737', - [when(ghc_dynamic(), omit_ways(['profasm'])), extra_files(['T16737include/'])], - compile_and_run, - ['-optP=-isystem -optP=T16737include']) |