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