File tree Expand file tree Collapse file tree 8 files changed +104
-0
lines changed
cabal-testsuite/PackageTests/CCompilerOverride Expand file tree Collapse file tree 8 files changed +104
-0
lines changed Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE ForeignFunctionInterface #-}
2
+
3
+ module Main (main ) where
4
+
5
+ foreign import ccall " foo" foo :: Int -> Int
6
+
7
+ main :: IO ()
8
+ main = do
9
+ let x = foo 0
10
+ y = x
11
+ let x = y
12
+ print x
13
+ pure ()
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ if which cc > /dev/null 2>&1 ; then
4
+ cc -DNOERROR6 " ${@ } "
5
+ elif which gcc > /dev/null 2>&1 ; then
6
+ gcc -DNOERROR6 " ${@ } "
7
+ elif which clang > /dev/null 2>&1 ; then
8
+ clang -DNOERROR6 " ${@ } "
9
+ else
10
+ echo " Cannot find C compiler" >&2
11
+ exit 1
12
+ fi
13
+
Original file line number Diff line number Diff line change
1
+ @ echo OFF
2
+
3
+ where /q gcc.exe
4
+
5
+ IF %ERRORLEVEL% EQU 0 (
6
+ call gcc.exe -DNOERROR6 %*
7
+ EXIT /B %ERRORLEVEL%
8
+ )
9
+
10
+ ECHO " Cannot find C compiler"
11
+ EXIT /B 1
Original file line number Diff line number Diff line change
1
+
2
+ #ifndef NOERROR1
3
+ #error "NOERROR1 was not passed"
4
+ #endif
5
+
6
+ #ifndef NOERROR2
7
+ #error "NOERROR2 was not passed"
8
+ #endif
9
+
10
+ #ifndef NOERROR3
11
+ #error "NOERROR3 was not passed"
12
+ #endif
13
+
14
+ #ifndef NOERROR4
15
+ #error "NOERROR4 was not passed"
16
+ #endif
17
+
18
+ #ifndef NOERROR5
19
+ #error "NOERROR5 was not passed"
20
+ #endif
21
+
22
+ #ifndef NOERROR6
23
+ #error "NOERROR6 was not passed"
24
+ #endif
25
+
26
+ int foo (int x ) {
27
+ return x + 42 ;
28
+ }
Original file line number Diff line number Diff line change
1
+ name : my
2
+ version : 0.1
3
+ license : BSD3
4
+ cabal-version : >= 1.10
5
+ build-type : Simple
6
+
7
+ executable foo
8
+ default-language : Haskell2010
9
+ main-is : Main.hs
10
+ c-sources : foo.c
11
+ build-depends : base
12
+ ghc-options : -DNOERROR4
13
+ cc-options : -DNOERROR5 -march=native
Original file line number Diff line number Diff line change
1
+ # Setup configure
2
+ Configuring my-0.1...
3
+ Warning: Instead of 'ghc-options: -DNOERROR4' use 'cpp-options: -DNOERROR4'
4
+ # Setup build
Original file line number Diff line number Diff line change
1
+ # Setup configure
2
+ Configuring my-0.1...
3
+ Warning: Instead of 'ghc-options: -DNOERROR4' use 'cpp-options: -DNOERROR4'
4
+ # Setup build
Original file line number Diff line number Diff line change
1
+ import Test.Cabal.Prelude
2
+
3
+ -- Test that all the respective defines -DNOERROR... specified in variosu ways
4
+ -- all end up routed to the C compiler. Otherwise the C file we depend on will
5
+ -- not compile.
6
+ main = setupAndCabalTest $ do
7
+ isWin <- isWindows
8
+ env <- getTestEnv
9
+ let pwd = testCurrentDir env
10
+ customCC = pwd ++ " /custom-cc" ++ if isWin then " .bat" else " "
11
+
12
+ setup " configure"
13
+ [ " --ghc-option=-DNOERROR1"
14
+ , " --ghc-option=-optc=-DNOERROR2"
15
+ , " --ghc-option=-optP=-DNOERROR3"
16
+ , " --with-gcc=" ++ customCC
17
+ ]
18
+ setup " build" [" -v2" ]
You can’t perform that action at this time.
0 commit comments