Skip to content

Commit ba28fe2

Browse files
jasagredoerikd
authored andcommitted
Die if dynamic executable is requested on Windows
1 parent dc4f2d5 commit ba28fe2

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

Cabal/src/Distribution/Simple/Configure.hs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,9 @@ configureComponents
13051305
when (LBC.relocatable $ LBC.withBuildOptions lbc) $
13061306
checkRelocatable verbosity pkg_descr lbi
13071307

1308+
when (LBC.withDynExe $ LBC.withBuildOptions lbc) $
1309+
checkSharedExes verbosity lbi
1310+
13081311
-- TODO: This is not entirely correct, because the dirs may vary
13091312
-- across libraries/executables
13101313
let dirs = absoluteInstallDirs pkg_descr lbi NoCopyDest
@@ -2719,6 +2722,18 @@ checkPackageProblems verbosity dir gpkg pkg = do
27192722
classEW (PackageDistSuspiciousWarn _) = Nothing
27202723
classEW (PackageDistInexcusable _) = Nothing
27212724

2725+
-- | Perform checks if a shared executable can be built
2726+
checkSharedExes
2727+
:: Verbosity
2728+
-> LocalBuildInfo
2729+
-> IO ()
2730+
checkSharedExes verbosity lbi =
2731+
when (os == Windows) $
2732+
dieWithException verbosity $
2733+
NoOSSupport os "shared executables"
2734+
where
2735+
(Platform _ os) = hostPlatform lbi
2736+
27222737
-- | Preform checks if a relocatable build is allowed
27232738
checkRelocatable
27242739
:: Verbosity
@@ -2741,7 +2756,7 @@ checkRelocatable verbosity pkg lbi =
27412756
checkOS =
27422757
unless (os `elem` [OSX, Linux]) $
27432758
dieWithException verbosity $
2744-
NoOSSupport os
2759+
NoOSSupport os "relocatable builds"
27452760
where
27462761
(Platform _ os) = hostPlatform lbi
27472762

Cabal/src/Distribution/Simple/Errors.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ data CabalException
138138
| BadVersion String String PkgconfigVersion
139139
| UnknownCompilerException
140140
| NoWorkingGcc
141-
| NoOSSupport OS
141+
| NoOSSupport OS String
142142
| NoCompilerSupport String
143143
| InstallDirsNotPrefixRelative (InstallDirs FilePath)
144144
| ExplainErrors (Maybe (Either [Char] [Char])) [String]
@@ -622,10 +622,11 @@ exceptionMessage e = case e of
622622
++ "non-standard location you can use the --with-gcc "
623623
++ "flag to specify it."
624624
]
625-
NoOSSupport os ->
625+
NoOSSupport os what ->
626626
"Operating system: "
627627
++ prettyShow os
628-
++ ", does not support relocatable builds"
628+
++ ", does not support "
629+
++ what
629630
NoCompilerSupport comp ->
630631
"Compiler: "
631632
++ comp

changelog.d/pr-10217

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
synopsis: Do not try to build dynamic executables on Windows
2+
packages: Cabal
3+
prs: #10217
4+
5+
description: {
6+
7+
- Cabal will now exit with a descriptive error message instead of attempting to
8+
build a dynamic executable on Windows.
9+
10+
}

0 commit comments

Comments
 (0)