summaryrefslogtreecommitdiff
path: root/compiler/main/SysTools.lhs
Commit message (Collapse)AuthorAgeFilesLines
* compiler: de-lhs main/Austin Seipp2014-12-031-1594/+0
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix obscure problem with using the system linker (#8935)Peter Trommler2014-11-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In a statically linked GHCi symbol `environ` resolves to NULL when called from a Haskell script. When resolving symbols in a Haskell script we need to search the executable program and its dependent (DT_NEEDED) shared libraries first and then search the loaded libraries. We want to be able to override functions in loaded libraries later. Libraries must be opened with local scope (RTLD_LOCAL) and not global. The latter adds all symbols to the executable program's symbols where they are then searched in loading order. We want reverse loading order. When libraries are loaded with local scope the dynamic linker cannot use symbols in that library when resolving the dependencies in another shared library. This changes the way files compiled to object code must be linked into temporary shared libraries. We link with the last temporary shared library created so far if it exists. Since each temporary shared library is linked to the previous temporary shared library the dynamic linker finds the latest definition of a symbol by following the dependency chain. See also Note [RTLD_LOCAL] for a summary of the problem and solution. Cherry-picked commit 2f8b4c Changed linker argument ordering On some ELF systems GNU ld (and others?) default to --as-needed and the order of libraries in the link matters. The last temporary shared library, must appear before all other libraries. Switching the position of extra_ld_inputs and lib_path_objs does that. Fixes #8935 and #9186 Reviewers: austin, hvr, rwbarton, simonmar Reviewed By: simonmar Subscribers: thomie, carter, simonmar Differential Revision: https://phabricator.haskell.org/D349 GHC Trac Issues: #8935, #9186, #9480
* Fix detection of GNU gold linker if invoked via gcc with parametersSebastian Dröge2014-11-181-2/+5
| | | | | | | | | | | Previously the linker was called without any commandline parameters to detect whether bfd or gold is used. However the -fuse-ld parameter can be used to switch between gold and bfd and should be taken into account here. Trac #9336 Signed-off-by: Austin Seipp <austin@well-typed.com>
* systools: fix gcc version detecton on non-english localeSergei Trofimovich2014-09-021-4/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: ghc runs 'gcc -v' to check if we run under vanilla gcc or disaguised clang by checking for string "gcc version <something>" But this check does not always work as gcc has that string localized via gettext mechanism: (some gcc's locale strings) be.po-msgstr "версія gcc %s\n" da.po-msgstr "GCC version %s\n" de.po-msgstr "gcc-Version %s %s\n" el.po-msgstr "έκδοση gcc %s\n" ... To ping gcc to English locale we now override environment variable with 'LANGUAGE=en' value. Fixes Issue #8825 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: validate Reviewers: austin Reviewed By: austin Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D185 GHC Trac Issues: #8825
* systools info: fix warning about C compiler (message said about linker)Sergei Trofimovich2014-08-101-2/+2
| | | | | | | | | | | | | | Summary: Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: build-tested Reviewers: austin Reviewed By: austin Subscribers: phaskell, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D132
* Minor wordsmithing of commentsGabor Greif2014-08-011-4/+4
|
* add Solaris' linker warning messages filtering into link phaseKarel Gardas2014-07-281-1/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Solaris ld emits harmless warning messages about unresolved symbol in case of compiling into shared library when we do not link against all the required libs. That is the case of GHC which does not link against RTS library explicitly in order to be able to chose the library later based on binary application linking parameters. The warnings look like: Undefined first referenced symbol in file stg_ap_n_fast ./T2386_Lib.o stg_upd_frame_info ./T2386_Lib.o templatezmhaskell_LanguageziHaskellziTHziLib_litE_closure ./T2386_Lib.o templatezmhaskell_LanguageziHaskellziTHziLib_appE_closure ./T2386_Lib.o templatezmhaskell_LanguageziHaskellziTHziLib_conE_closure ./T2386_Lib.o templatezmhaskell_LanguageziHaskellziTHziSyntax_mkNameGzud_closure ./T2386_Lib.o newCAF ./T2386_Lib.o stg_bh_upd_frame_info ./T2386_Lib.o stg_ap_ppp_fast ./T2386_Lib.o templatezmhaskell_LanguageziHaskellziTHziLib_stringL_closure ./T2386_Lib.o stg_ap_p_fast ./T2386_Lib.o stg_ap_pp_fast ./T2386_Lib.o ld: warning: symbol referencing errors this is actually coming from T2386 testcase. The emitting of those warnings is also a reason why so many TH testcases fail on Solaris. The patch provides filter which filters out only linker warnings. Test Plan: validate Reviewers: austin Reviewed By: austin Subscribers: phaskell, simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D94
* Rename PackageId to PackageKey, distinguishing it from Cabal's PackageId.Edward Z. Yang2014-07-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, both Cabal and GHC defined the type PackageId, and we expected them to be roughly equivalent (but represented differently). This refactoring separates these two notions. A package ID is a user-visible identifier; it's the thing you write in a Cabal file, e.g. containers-0.9. The components of this ID are semantically meaningful, and decompose into a package name and a package vrsion. A package key is an opaque identifier used by GHC to generate linking symbols. Presently, it just consists of a package name and a package version, but pursuant to #9265 we are planning to extend it to record other information. Within a single executable, it uniquely identifies a package. It is *not* an InstalledPackageId, as the choice of a package key affects the ABI of a package (whereas an InstalledPackageId is computed after compilation.) Cabal computes a package key for the package and passes it to GHC using -package-name (now *extremely* misnamed). As an added bonus, we don't have to worry about shadowing anymore. As a follow on, we should introduce -current-package-key having the same role as -package-name, and deprecate the old flag. This commit is just renaming. The haddock submodule needed to be updated. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D79 Conflicts: compiler/main/HscTypes.lhs compiler/main/Packages.lhs utils/haddock
* Control CPP through settings file (#8683)Carter Tazio Schonwald2014-07-021-4/+4
| | | | | | | | | | | | | | | | Summary: Allow the CPP program and flag choices for GHC be configured via the the ghc settings file Test Plan: ran validate yesterday Reviewers: hvr, austin, mzero, simonmar Reviewed By: austin, mzero, simonmar Subscribers: mzero, simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D26
* Fix #9047Austin Seipp2014-06-231-3/+6
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-151-0/+2
| | | | | | | | | | | | | | | | | | In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been reorganized, while following the convention, to - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before any `{-# OPTIONS_GHC #-}`-lines. - Moreover, if the list of language extensions fit into a single `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each individual language extension. In both cases, try to keep the enumeration alphabetically ordered. (The latter layout is preferable as it's more diff-friendly) While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
* windows: Fix #8870Austin Seipp2014-04-041-2/+43
| | | | | | | | | | This bumps the amount of default reserved and committed stack for GHC executables to 8mb, to work around #8870. A proper fix should happen in 7.8.2 See note [Windows stack usage] in SysTools for the details. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix inplace dynamic linking on OS X (#8266)Christiaan Baaj2014-01-281-4/+3
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Cache compiler info in DynFlagsAustin Seipp2014-01-151-2/+52
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Typo in commentGabor Greif2014-01-141-1/+1
|
* Add Solaris linker support to SysToolsKarel Gardas2014-01-141-0/+9
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Re-order preprocessor args to agree with User Guide (fixes #8602)Chris Heller2014-01-071-1/+1
| | | | | | The section of the User Guide in reference is 4.12.4 Signed-off-by: Austin Seipp <austin@well-typed.com>
* SysTools.getTempDir: don't retry after catching a does-not-exist errorPatrick Palka2013-11-081-1/+1
| | | | | | | | | | | | | | | Previously, a command like $ ghc -tmpdir blah Foo where the directory blah/ does not exist, would loop forever: getTempDir would repeatedly try to create a temporary subdirectory inside blah/, catching the does-not-exist error thrown by createDirectory and retrying, in vain, with another suffix. Now instead the above compiler invocation will fail with an error: blah/ghc25781_0: createDirectory: does not exist (No such file or directory)
* Merge remote-tracking branch 'origin/master' into ghc-parmake-gsocPatrick Palka2013-09-061-0/+3
|\
| * Fix annoying iOS linker warnings (#8208)Austin Seipp2013-09-041-0/+3
| | | | | | | | | | Authored-by: Luke Iannini <lukexi@me.com> Signed-off-by: Austin Seipp <aseipp@pobox.com>
* | Merge branch 'master' into ghc-parmake-gsocPatrick Palka2013-08-301-2/+15
|\ \ | |/ | | | | | | | | Conflicts: compiler/main/DynFlags.hs compiler/utils/FastString.lhs
| * Rework how iOS does linking (#8127)Austin Seipp2013-08-281-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | iOS has some particular constraints about how applications can be built: * We must generate a static library (.a) since XCode does the final link. * We need to carefully give the right set of arguments to libtool in the case we're generating an archive. * Dynamic linking isn't supported. * It can only be done on OS X. This patch cleans up all of the above. We add a new flag `-staticlib` (only supported on Darwin) that allows us to produce archive files using libtool, and a -pgmlibtool flag to control which 'libtool' executable to use. This fixes #8127. I believe this is the last piece missing from the iOS cross compiler. Authored-by: Luke Iannini <lukexi@me.com> Authored-by: Maxwell Swadling <maxwellswadling@gmail.com> Authored-by: Stephen Blackheath <...@blacksapphire.com> Signed-off-by: Austin Seipp <aseipp@pobox.com>
* | SysTools: make various functions thread-safePatrick Palka2013-08-261-40/+63
|/
* Detect linker information at runtime. Fixes Trac #6063Austin Seipp2013-06-161-3/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we did ./configure time checks to see if 'GNU ld' supported certain options. If it does, we bake those options into the link step. See Trac #5240. Unfortunately, the linker we use at runtime can change for several reasons. One is that the user specifies -pgml 'foo'. The other is if /usr/bin/ld or whatnot changes from when GHC was built. Those options mentioned earlier are specific to GNU ld, but many systems support GNU gold too. This is Trac #6063. So we need to check at runtime what linker we're using. This is actually a little bit complicated because we normally use the C compiler as our linker. Windows and OS X are also special here. Finally, this patch also unconditionally gives '--hash-size=31' and '--reduce-memory-overheads' to the system linker if it's GNU ld. These options have been supported for 8+ years from what I can see, and there are probably a lot of other reasons why GHC would not work with such an ancient binutils, all things considered. See Note [Run-time linker info] in SysTools for details. There are plenty of comments as well in the surrounding code. Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Handle -opt<blah> options more consistently (#7909)Simon Marlow2013-05-211-52/+59
| | | | | Now these are always added by the run<blah> functions in SysTools, so we never miss any out. Several cleanups resulted.
* Link to the right RTS whenever we build a .dll on WindowsIan Lynagh2013-05-151-3/+15
| | | | | When GHCi makes temporary DLLs, those also need to be linked against the right RTS, or we won't be able to load them.
* Add support for OSX ld's -filelist flagIan Lynagh2013-03-181-0/+2
| | | | | Without it, when linking the split objects for Language.Haskell.TH.Syntax, the commandline was too long when listing all the files directly.
* Split SettingsCCompilerFlags into non-link and link portionsGabor Greif2013-02-251-1/+2
| | | | | | | | | This fixes certain older GCCs which do not accept link options when assembling or compiling: ppc_85xx-gcc: --hash-size=31: linker input file unused because linking not done ppc_85xx-gcc: --reduce-memory-overheads: linker input file unused because linking not done and diagnose this to stderr.
* Use throwIO rather than throwIan Lynagh2013-01-301-1/+1
|
* Change a few throwGhcException uses to throwGhcExceptionIOIan Lynagh2013-01-301-4/+4
|
* Fix llvm backend when 32bit build on 64bit OSX. (#7617)David Terei2013-01-221-3/+10
|
* Replace all uses of ghcError with throwGhcException and purge ghcError.Erik de Castro Lopo2012-11-301-4/+4
|
* Some alpha renamingIan Lynagh2012-10-161-6/+6
| | | | | Mostly d -> g (matching DynFlag -> GeneralFlag). Also renamed if* to when*, matching the Haskell if/when names
* When dynamic-by-default, don't use the GHCi linkerIan Lynagh2012-10-131-0/+170
| | | | We instead link objects into a temporary DLL and dlopen that
* Add more modes to mkDerivedConstantsIan Lynagh2012-09-131-1/+10
| | | | We now generate a platformConstants file that we can read at runtime.
* Add "Unregisterised" as a field in the settings fileIan Lynagh2012-08-071-13/+11
| | | | | | To explicitly choose whether you want an unregisterised build you now need to use the "--enable-unregisterised"/"--disable-unregisterised" configure flags.
* Make tablesNextToCode "dynamic"Ian Lynagh2012-08-061-1/+15
| | | | | This is a bit odd by itself, but it's a stepping stone on the way to putting "target unregisterised" into the settings file.
* More more ld-related settings into the settings fileIan Lynagh2012-08-051-0/+11
| | | | Related to #4862
* Improve some code layout in SysToolsIan Lynagh2012-08-051-138/+139
|
* GHC 7.4 is now required for building HEADIan Lynagh2012-07-201-8/+0
|
* Make a picPOpts functionIan Lynagh2012-07-161-5/+1
| | | | | We now handle the preprocessor options the same way as the gcc options (picCCOpts).
* Fix a couple of warningsIan Lynagh2012-07-161-2/+5
|
* Use errorMsg over putMsg when appropriate.David Terei2012-06-251-3/+3
|
* Pass DynFlags to the LogActionIan Lynagh2012-06-111-2/+2
| | | | | | | A side-effect is that we can no longer use the LogAction in defaultErrorHandler, as we don't have DynFlags at that point. But all that defaultErrorHandler did is to print Strings as SevFatal, so now it takes a 'FatalMessager' instead.
* Don't use stdcall on Win64: It isn't supported; ccall is used insteadIan Lynagh2012-05-161-1/+11
|
* Abstract out the hFlush calls in the GHC APIIan Lynagh2012-02-241-1/+2
| | | | | | stdout/stderr might be closed, so we can't just hFlush them. So we instead allow configuration in the same way that log_action is configurable.
* Enable llvm tool paths to be set with ./configureDavid Terei2012-01-101-2/+2
| | | | Patch from Karel Gardas!
* Store the word size as determined by configure, in the settings file (#5735)Simon Marlow2012-01-041-0/+2
| | | | | Now target32bit works for all targets without any manual intervention, as it should do. #5735 was a portability regression.
* Detect cases where as(1) doesn't recognise .ident directive (#5408)PHO2011-12-081-0/+2
| | | | .ident directives are usually ignored by as(1), and in some cases (like Darwin/PPC) they even raise an error.
* copyFileWithHeader: write the header in UTF-8Simon Marlow2011-11-241-1/+13
|