@@ -513,101 +513,105 @@ ppHsc2hs bi lbi clbi =
513
513
-- directly, or via a response file.
514
514
genPureArgs :: Version -> ConfiguredProgram -> String -> String -> [String ]
515
515
genPureArgs hsc2hsVersion gccProg inFile outFile =
516
- -- Additional gcc options
517
- [ " --cflag=" ++ opt
518
- | opt <-
519
- programDefaultArgs gccProg
520
- ++ programOverrideArgs gccProg
521
- ]
522
- ++ [ " --lflag=" ++ opt
523
- | opt <-
524
- programDefaultArgs gccProg
525
- ++ programOverrideArgs gccProg
526
- ]
527
- -- OSX frameworks:
528
- ++ [ what ++ " =-F" ++ opt
529
- | isOSX
530
- , opt <- nub (concatMap Installed. frameworkDirs pkgs)
531
- , what <- [" --cflag" , " --lflag" ]
532
- ]
533
- ++ [ " --lflag=" ++ arg
534
- | isOSX
535
- , opt <- map getSymbolicPath (PD. frameworks bi) ++ concatMap Installed. frameworks pkgs
536
- , arg <- [" -framework" , opt]
537
- ]
538
- -- Note that on ELF systems, wherever we use -L, we must also use -R
539
- -- because presumably that -L dir is not on the normal path for the
540
- -- system's dynamic linker. This is needed because hsc2hs works by
541
- -- compiling a C program and then running it.
542
-
543
- ++ [" --cflag=" ++ opt | opt <- platformDefines lbi]
544
- -- Options from the current package:
545
- ++ [" --cflag=-I" ++ u dir | dir <- PD. includeDirs bi]
546
- ++ [ " --cflag=-I" ++ u (buildDir lbi </> unsafeCoerceSymbolicPath relDir)
547
- | relDir <- mapMaybe symbolicPathRelative_maybe $ PD. includeDirs bi
548
- ]
549
- ++ [ " --cflag=" ++ opt
550
- | opt <-
551
- PD. ccOptions bi
552
- ++ PD. cppOptions bi
553
- -- hsc2hs uses the C ABI
516
+ cflags
517
+ ++ ldflags
518
+ ++ preccldFlags
519
+ ++ hsc2hsOptions bi
520
+ ++ postccldFlags
521
+ ++ [" -o" , outFile, inFile]
522
+ where
523
+ ldflags =
524
+ map (" --lflag=" ++ ) $
525
+ concat
526
+ [ programDefaultArgs gccProg ++ programOverrideArgs gccProg
527
+ , osxFrameworkDirs
528
+ , [ arg
529
+ | isOSX
530
+ , opt <- map getSymbolicPath (PD. frameworks bi) ++ concatMap Installed. frameworks pkgs
531
+ , arg <- [" -framework" , opt]
532
+ ]
533
+ , -- Note that on ELF systems, wherever we use -L, we must also use -R
534
+ -- because presumably that -L dir is not on the normal path for the
535
+ -- system's dynamic linker. This is needed because hsc2hs works by
536
+ -- compiling a C program and then running it.
537
+
538
+ -- Options from the current package:
539
+ [ " -L" ++ u opt
540
+ | opt <-
541
+ if withFullyStaticExe lbi
542
+ then PD. extraLibDirsStatic bi
543
+ else PD. extraLibDirs bi
544
+ ]
545
+ , [ " -Wl,-R," ++ u opt
546
+ | isELF
547
+ , opt <-
548
+ if withFullyStaticExe lbi
549
+ then PD. extraLibDirsStatic bi
550
+ else PD. extraLibDirs bi
551
+ ]
552
+ , [" -l" ++ opt | opt <- PD. extraLibs bi]
553
+ , PD. ldOptions bi
554
+ , -- Options from dependent packages
555
+ [ opt
556
+ | pkg <- pkgs
557
+ , opt <-
558
+ [" -L" ++ opt | opt <- Installed. libraryDirs pkg]
559
+ ++ [ " -Wl,-R," ++ opt | isELF, opt <- Installed. libraryDirs pkg
560
+ ]
561
+ ++ [ " -l" ++ opt
562
+ | opt <-
563
+ if withFullyStaticExe lbi
564
+ then Installed. extraLibrariesStatic pkg
565
+ else Installed. extraLibraries pkg
566
+ ]
567
+ ++ Installed. ldOptions pkg
568
+ ]
569
+ ]
570
+
571
+ cflags =
572
+ map (" --cflag=" ++ ) $
573
+ concat
574
+ [ programDefaultArgs gccProg ++ programOverrideArgs gccProg
575
+ , osxFrameworkDirs
576
+ , platformDefines lbi
577
+ , -- Options from the current package:
578
+ [" -I" ++ u dir | dir <- PD. includeDirs bi]
579
+ , [ " -I" ++ u (buildDir lbi </> unsafeCoerceSymbolicPath relDir)
580
+ | relDir <- mapMaybe symbolicPathRelative_maybe $ PD. includeDirs bi
581
+ ]
582
+
583
+ , -- hsc2hs uses the C ABI
554
584
-- We assume that there are only C sources
555
585
-- and C++ functions are exported via a C
556
586
-- interface and wrapped in a C source file.
557
587
-- Therefore we do not supply C++ flags
558
588
-- because there will not be C++ sources.
559
589
--
560
590
-- DO NOT add PD.cxxOptions unless this changes!
561
- ]
562
- ++ [ " --cflag=" ++ opt
563
- | opt <-
564
- [ " -I" ++ u (autogenComponentModulesDir lbi clbi)
565
- , " -I" ++ u (autogenPackageModulesDir lbi)
566
- , " -include"
567
- , u $ autogenComponentModulesDir lbi clbi </> makeRelativePathEx cppHeaderName
591
+ PD. ccOptions bi ++ PD. cppOptions bi
592
+
593
+ ,
594
+ [ " -I" ++ u (autogenComponentModulesDir lbi clbi)
595
+ , " -I" ++ u (autogenPackageModulesDir lbi)
596
+ , " -include"
597
+ , u $ autogenComponentModulesDir lbi clbi </> makeRelativePathEx cppHeaderName
598
+ ]
599
+
600
+ , -- Options from dependent packages
601
+ [ opt
602
+ | pkg <- pkgs
603
+ , opt <-
604
+ [" -I" ++ opt | opt <- Installed. includeDirs pkg]
605
+ ++ Installed. ccOptions pkg
606
+ ]
568
607
]
569
- ]
570
- ++ [ " --lflag=-L" ++ u opt
571
- | opt <-
572
- if withFullyStaticExe lbi
573
- then PD. extraLibDirsStatic bi
574
- else PD. extraLibDirs bi
575
- ]
576
- ++ [ " --lflag=-Wl,-R," ++ u opt
577
- | isELF
578
- , opt <-
579
- if withFullyStaticExe lbi
580
- then PD. extraLibDirsStatic bi
581
- else PD. extraLibDirs bi
582
- ]
583
- ++ [" --lflag=-l" ++ opt | opt <- PD. extraLibs bi]
584
- ++ [" --lflag=" ++ opt | opt <- PD. ldOptions bi]
585
- -- Options from dependent packages
586
- ++ [ " --cflag=" ++ opt
587
- | pkg <- pkgs
588
- , opt <-
589
- [" -I" ++ opt | opt <- Installed. includeDirs pkg]
590
- ++ Installed. ccOptions pkg
591
- ]
592
- ++ [ " --lflag=" ++ opt
593
- | pkg <- pkgs
594
- , opt <-
595
- [" -L" ++ opt | opt <- Installed. libraryDirs pkg]
596
- ++ [ " -Wl,-R," ++ opt | isELF, opt <- Installed. libraryDirs pkg
597
- ]
598
- ++ [ " -l" ++ opt
599
- | opt <-
600
- if withFullyStaticExe lbi
601
- then Installed. extraLibrariesStatic pkg
602
- else Installed. extraLibraries pkg
603
- ]
604
- ++ Installed. ldOptions pkg
605
- ]
606
- ++ preccldFlags
607
- ++ hsc2hsOptions bi
608
- ++ postccldFlags
609
- ++ [" -o" , outFile, inFile]
610
- where
608
+
609
+ osxFrameworkDirs =
610
+ [ " -F" ++ opt
611
+ | isOSX
612
+ , opt <- ordNub (concatMap Installed. frameworkDirs pkgs)
613
+ ]
614
+
611
615
-- hsc2hs flag parsing was wrong
612
616
-- (see -- https://github.com/haskell/hsc2hs/issues/35)
613
617
-- so we need to put -- --cc/--ld *after* hsc2hsOptions,
0 commit comments