[Git][ghc/ghc][wip/24286] driver: Set -DPROFILING when compiling C++ sources with profiling

Zubin (@wz1000) gitlab at gitlab.haskell.org
Mon Jan 8 09:50:16 UTC 2024



Zubin pushed to branch wip/24286 at Glasgow Haskell Compiler / GHC


Commits:
3603a452 by Zubin Duggal at 2024-01-08T15:19:51+05:30
driver: Set -DPROFILING when compiling C++ sources with profiling

Fixes #24286

- - - - -


5 changed files:

- compiler/GHC/Driver/Session.hs
- compiler/GHC/Platform/Ways.hs
- testsuite/tests/driver/Makefile
- + testsuite/tests/driver/T24286.cpp
- testsuite/tests/driver/all.T


Changes:

=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -438,7 +438,8 @@ opt_c                 :: DynFlags -> [String]
 opt_c dflags = concatMap (wayOptc (targetPlatform dflags)) (ways dflags)
             ++ toolSettings_opt_c (toolSettings dflags)
 opt_cxx               :: DynFlags -> [String]
-opt_cxx dflags= toolSettings_opt_cxx $ toolSettings dflags
+opt_cxx dflags = concatMap (wayOptcxx (targetPlatform dflags)) (ways dflags)
+           ++ toolSettings_opt_cxx (toolSettings dflags)
 opt_a                 :: DynFlags -> [String]
 opt_a dflags= toolSettings_opt_a $ toolSettings dflags
 opt_l                 :: DynFlags -> [String]


=====================================
compiler/GHC/Platform/Ways.hs
=====================================
@@ -31,6 +31,7 @@ module GHC.Platform.Ways
    , wayGeneralFlags
    , wayUnsetGeneralFlags
    , wayOptc
+   , wayOptcxx
    , wayOptl
    , wayOptP
    , wayDesc
@@ -177,6 +178,9 @@ wayOptc _ WayDebug      = []
 wayOptc _ WayDyn        = []
 wayOptc _ WayProf       = ["-DPROFILING"]
 
+wayOptcxx :: Platform -> Way -> [String]
+wayOptcxx = wayOptc -- Use the same flags as C
+
 -- | Pass these options to linker when enabling this way
 wayOptl :: Platform -> Way -> [String]
 wayOptl _ (WayCustom {}) = []


=====================================
testsuite/tests/driver/Makefile
=====================================
@@ -808,5 +808,3 @@ T23339B:
 	"$(TEST_HC)" -tmpdir "$(PWD)/tmp" $(TEST_HC_OPTS) -v0 T23339B.hs -finfo-table-map
 	# Check that the file is kept and is the right one
 	find . -name "*.c" -exec cat {} \; | grep "init__ip_init"
-
-


=====================================
testsuite/tests/driver/T24286.cpp
=====================================
@@ -0,0 +1,7 @@
+#if !defined(PROFILING)
+#error PROFILING flag not set for C++ files, see #24286
+#endif
+
+int main() {
+  return 0;
+}


=====================================
testsuite/tests/driver/all.T
=====================================
@@ -326,3 +326,4 @@ test('T23339', req_c, makefile_test, [])
 test('T23339B', [extra_files(['T23339.hs']), req_c], makefile_test, [])
 test('T23613', normal, compile_and_run, ['-this-unit-id=foo'])
 test('T23944', [unless(have_dynamic(), skip), extra_files(['T23944A.hs'])], multimod_compile, ['T23944 T23944A', '-fprefer-byte-code -fbyte-code -fno-code -dynamic-too -fwrite-interface'])
+test('T24286', [cpp_src, unless(have_profiling(), skip), extra_files(['T24286.cpp'])], compile, ['-prof -no-hs-main'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3603a4526ae63f8d8566279342bb15b615b7142a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3603a4526ae63f8d8566279342bb15b615b7142a
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240108/2418f969/attachment-0001.html>


More information about the ghc-commits mailing list