-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{-# LANGUAGE ForeignFunctionInterface #-} | ||
|
||
module Main (main) where | ||
|
||
foreign import ccall "foo" foo :: Int -> Int | ||
|
||
main :: IO () | ||
main = do | ||
let x = foo 0 | ||
y = x | ||
let x = y | ||
print x | ||
pure () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
if which cc >/dev/null 2>&1; then | ||
cc -DNOERROR6 "${@}" | ||
elif which gcc >/dev/null 2>&1; then | ||
gcc -DNOERROR6 "${@}" | ||
elif which clang >/dev/null 2>&1; then | ||
clang -DNOERROR6 "${@}" | ||
else | ||
echo "Cannot find C compiler" >&2 | ||
exit 1 | ||
fi | ||
|
11 changes: 11 additions & 0 deletions
11
cabal-testsuite/PackageTests/CCompilerOverride/custom-cc.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@echo OFF | ||
|
||
where /q gcc.exe | ||
|
||
IF %ERRORLEVEL% EQU 0 ( | ||
call gcc.exe -DNOERROR6 %* | ||
EXIT /B %ERRORLEVEL% | ||
) | ||
|
||
ECHO "Cannot find C compiler" | ||
EXIT /B 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
#ifndef NOERROR1 | ||
#error "NOERROR1 was not passed" | ||
#endif | ||
|
||
#ifndef NOERROR2 | ||
#error "NOERROR2 was not passed" | ||
#endif | ||
|
||
#ifndef NOERROR3 | ||
#error "NOERROR3 was not passed" | ||
#endif | ||
|
||
#ifndef NOERROR4 | ||
#error "NOERROR4 was not passed" | ||
#endif | ||
|
||
#ifndef NOERROR5 | ||
#error "NOERROR5 was not passed" | ||
#endif | ||
|
||
#ifndef NOERROR6 | ||
#error "NOERROR6 was not passed" | ||
#endif | ||
|
||
int foo(int x) { | ||
return x + 42; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: my | ||
version: 0.1 | ||
license: BSD3 | ||
cabal-version: >= 1.10 | ||
build-type: Simple | ||
|
||
executable foo | ||
default-language: Haskell2010 | ||
main-is: Main.hs | ||
c-sources: foo.c | ||
build-depends: base | ||
ghc-options: -DNOERROR4 | ||
cc-options: -DNOERROR5 -march=native |
4 changes: 4 additions & 0 deletions
4
cabal-testsuite/PackageTests/CCompilerOverride/setup.cabal.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Setup configure | ||
Configuring my-0.1... | ||
Warning: Instead of 'ghc-options: -DNOERROR4' use 'cpp-options: -DNOERROR4' | ||
# Setup build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Setup configure | ||
Configuring my-0.1... | ||
Warning: Instead of 'ghc-options: -DNOERROR4' use 'cpp-options: -DNOERROR4' | ||
# Setup build |
18 changes: 18 additions & 0 deletions
18
cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Test.Cabal.Prelude | ||
|
||
-- Test that all the respective defines -DNOERROR... specified in variosu ways | ||
-- all end up routed to the C compiler. Otherwise the C file we depend on will | ||
-- not compile. | ||
main = setupAndCabalTest $ do | ||
isWin <- isWindows | ||
env <- getTestEnv | ||
let pwd = testCurrentDir env | ||
customCC = pwd ++ "/custom-cc" ++ if isWin then ".bat" else "" | ||
|
||
setup "configure" | ||
[ "--ghc-option=-DNOERROR1" | ||
, "--ghc-option=-optc=-DNOERROR2" | ||
, "--ghc-option=-optP=-DNOERROR3" | ||
, "--with-gcc=" ++ customCC | ||
] | ||
setup "build" ["-v2"] |