-
Notifications
You must be signed in to change notification settings - Fork 732
Fix --host= triple mangling during cross-compilation #11718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jappeace
wants to merge
9
commits into
haskell:master
Choose a base branch
from
jappeace:fix-host-triple-mangling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fb2cc4c
Fix --host= triple mangling during cross-compilation
5910bf0
don't show wrong tuple
jappeace 5629641
use like words and such
jappeace eb68627
explicit names for triple
jappeace c5b0ca3
improve changelog
jappeace 7b1a466
Apply suggestions from code review
jappeace 8c5d401
Update target comment such we don't confuse host/target
jappeace 5aa5349
Fix warning
jappeace 6617792
FORMATTTTT
jappeace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| module A where |
This file contains hidden or 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,6 @@ | ||
| module Main (main) where | ||
|
|
||
| import Distribution.Simple | ||
|
|
||
| main :: IO () | ||
| main = defaultMainWithHooks autoconfUserHooks |
This file contains hidden or 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 @@ | ||
| #!/bin/sh | ||
| # Minimal configure script that records its arguments. | ||
| # We write all args to configure-args.txt so the test can inspect them. | ||
| echo "$@" > configure-args.txt |
14 changes: 14 additions & 0 deletions
14
cabal-testsuite/PackageTests/ConfigureHostTriple/scripts/fake-ghc.sh
This file contains hidden or 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,14 @@ | ||
| #!/bin/sh | ||
|
|
||
| # A fake GHC that proxies the real GHC but overrides | ||
| # "Target platform" to simulate cross-compilation | ||
| # to x86_64-w64-mingw32. | ||
|
|
||
| case "$*" in | ||
| *--info*) | ||
| ghc "$@" | sed 's/("Target platform","[^"]*")/("Target platform","x86_64-w64-mingw32")/' | ||
| ;; | ||
| *) | ||
| exec ghc "$@" | ||
| ;; | ||
| esac |
42 changes: 42 additions & 0 deletions
42
cabal-testsuite/PackageTests/ConfigureHostTriple/setup.test.hs
This file contains hidden or 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,42 @@ | ||
| import Test.Cabal.Prelude | ||
| import Test.Cabal.Script (runghc) | ||
| import Control.Monad.IO.Class | ||
| import Data.List (isInfixOf) | ||
|
|
||
| -- When cross-compiling, Cabal passes a --host= flag to configure scripts. | ||
| -- The value should be the original GNU triple (e.g. x86_64-w64-mingw32), | ||
| -- not Cabal's canonical platform string (e.g. x86_64-windows). | ||
| -- | ||
| -- This test uses a fake GHC wrapper that reports "x86_64-w64-mingw32" | ||
| -- as its Target platform (simulating a cross-compiler), then checks | ||
| -- that the configure script receives --host=x86_64-w64-mingw32 | ||
| -- rather than the mangled --host=x86_64-windows. | ||
| main = do | ||
| skipIfWindows "uses sh script as fake ghc" | ||
| setupTest $ recordMode DoNotRecord $ do | ||
| env <- getTestEnv | ||
| let cwd = testCurrentDir env | ||
| fakeGhc = cwd </> "scripts" </> "fake-ghc.sh" | ||
| -- Run Setup.hs configure with our fake cross-compiler. | ||
| -- We call runghc ourselves to bypass the test framework's | ||
| -- --with-ghc which would override ours. | ||
| _ <- liftIO $ runghc | ||
| (testScriptEnv env) | ||
| (Just $ testTmpDir env) | ||
| (testEnvironment env) | ||
| ("." </> "Setup.hs") | ||
| [ "configure" | ||
| , "--distdir", testDistDir env | ||
| , "--with-compiler", fakeGhc | ||
| ] | ||
| -- The configure script writes its arguments to configure-args.txt | ||
| -- in its working directory (dist/build/). | ||
| let argsFile = testDistDir env </> "build" </> "configure-args.txt" | ||
| args <- liftIO $ readFile argsFile | ||
| -- The configure script should receive --host=x86_64-w64-mingw32 | ||
| -- (the original GNU triple), not --host=x86_64-windows. | ||
| unless ("--host=x86_64-w64-mingw32" `isInfixOf` args) $ | ||
| error $ unlines | ||
| [ "Expected --host=x86_64-w64-mingw32 in configure arguments" | ||
| , "but got: " ++ args | ||
| ] |
This file contains hidden or 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,9 @@ | ||
| cabal-version: 2.2 | ||
| name: test | ||
| version: 0 | ||
| build-type: Configure | ||
|
|
||
| library | ||
| exposed-modules: A | ||
| build-depends: base | ||
| default-language: Haskell2010 |
This file contains hidden or 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,15 @@ | ||
| --- | ||
| synopsis: Fix --host= triple mangling during cross-compilation | ||
| packages: [cabal-install] | ||
| prs: 11718 | ||
| issues: 5887 | ||
| --- | ||
|
|
||
| repairs (hopefully): https://github.com/haskell/cabal/issues/5887 | ||
|
|
||
| Cabal now passes the unchanged GHC target platform triple as the autoconf --host, instead of a simplified version. | ||
|
|
||
| For example, Cabal now passes the full `--host=x86_64-w64-mingw32` instead of the incorrect `--host=x86_64-windows`. | ||
|
|
||
| Adds an integration test which fails on master | ||
| and now succeeds. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.