@@ -206,6 +206,9 @@ modeExeFlags Interp1 = error "Cannot compile in Interp1 mode."
206206modeExeFlags Gibbon1 = [" --to-exe" , " --packed" , " --gibbon1" ]
207207modeExeFlags MPL = [" --mpl-exe" ]
208208
209+ ccFlags :: TestConfig -> [String ]
210+ ccFlags tc = maybe [] (\ cc -> [" --cc=" ++ cc]) (ccOverride tc)
211+
209212modeFileSuffix :: Mode -> String
210213modeFileSuffix GibbonNoCopies = " _gibbonNoCopies"
211214modeFileSuffix GibbonNoRan = " _gibbonNoRan"
@@ -339,6 +342,7 @@ data TestConfig = TestConfig
339342 -- It's a global parameter i.e it affects ALL tests.
340343 -- However, if a corresponding parameter is specified
341344 -- for a particular test, that has higher precedence.
345+ , ccOverride :: Maybe String -- ^ If set, pass --cc=<value> to all gibbon invocations.
342346 , checkPerf :: Bool -- ^ Should we also run the performance tests ?
343347 , onlyPerf :: Bool -- ^ If true, only run the benchmarks.
344348 , recordBenchmarks :: Bool -- ^ If true, record the results of running fresh benchmarks. Used via BenchRunner.
@@ -353,6 +357,7 @@ defaultTestConfig = TestConfig
353357 , testSummaryFile = " gibbon-test-summary.txt"
354358 , tempdir = " examples/build_tmp"
355359 , gRunModes = []
360+ , ccOverride = Nothing
356361 , checkPerf = False
357362 , onlyPerf = False
358363 , recordBenchmarks = False
@@ -366,6 +371,7 @@ instance FromJSON TestConfig where
366371 o .:? " test-summary-file" .!= (testSummaryFile defaultTestConfig) <*>
367372 o .:? " tempdir" .!= (tempdir defaultTestConfig) <*>
368373 o .:? " run-modes" .!= (gRunModes defaultTestConfig) <*>
374+ o .:? " cc" .!= (ccOverride defaultTestConfig) <*>
369375 o .:? " check-perf" .!= (checkPerf defaultTestConfig) <*>
370376 o .:? " only-perf" .!= (onlyPerf defaultTestConfig) <*>
371377 o .:? " run-benchmarks" .!= (recordBenchmarks defaultTestConfig) <*>
@@ -394,6 +400,9 @@ configParser dtc = TestConfig
394400 <*> option readM_modes (long " run-modes" <>
395401 help " Only run the tests in these modes" <>
396402 value (gRunModes dtc))
403+ <*> fmap (\ mb -> maybe (ccOverride dtc) Just mb)
404+ (OA. optional (strOption (long " cc" <>
405+ help " C compiler to use for all tests" )))
397406 <*> switch (long " check-perf" <>
398407 help " Run performance tests." <>
399408 showDefault)
@@ -521,7 +530,7 @@ runTest tc Test{name,dir,expectedResults,runModes,mb_anspath,test_flags} = do
521530 exepath = replaceExtension basename " .exe"
522531 cmd = " gibbon"
523532 -- The order of (++) is important. The PATH to the test file must always be at the end.
524- cmd_flags = modeRunFlags mode ++ test_flags ++
533+ cmd_flags = modeRunFlags mode ++ ccFlags tc ++ test_flags ++
525534 [ " --cfile=" ++ cpath ,
526535 " --exefile=" ++ exepath ,
527536 compiler_dir </> dir </> name ]
@@ -594,7 +603,7 @@ doNTrials tc mode t@Test{name,dir,numTrials,sizeParam,moreIters,isMegaBench,benc
594603
595604
596605 -- The order of (++) is important. The PATH to the test file must always be at the end.
597- cmd_flags = modeExeFlags mode ++ test_flags ++
606+ cmd_flags = modeExeFlags mode ++ ccFlags tc ++ test_flags ++
598607 [ " --cfile=" ++ cpath ,
599608 " --exefile=" ++ exepath ,
600609 compiler_dir </> dir </> name ]
0 commit comments