Open RichardWarfield opened 6 years ago
Interesting that system GHC exhibits the same problem. Have you tried adjusting the GHC settings file (in <GHC-ROOT>/lib/ghc-<GHC-VERSION>/settings
)?
I tried adding -fPIC to the system GHC settings (which I found in /usr/lib/ghc-8.2.2/settings).
("C compiler flags", " -fPIC -fno-stack-protector"),
("C compiler link flags", " -fPIC -fuse-ld=gold"),
Same result.
However -- I tried building a simple application (stack new teststack simple --system-ghc; stack build --system-ghc --profile
) and this did work. So, the issue seems to relate to how my project is set up. Which is strange because I don't think there is anything at all funky about my .cabal or stack.yaml configuration. I'll try to isolate the issue now.
OK, this seems to have something to do with building a shared foreign library. By removing the below foreign-library stanza from my .cabal file, I can make the problem go away.
foreign-library teststack-ffi
type: native-shared
lib-version-info: 6:3:2
-- if os(Windows)
-- options: standalone
-- mod-def-file: MyForeignLib.def
other-modules: FFI
hs-source-dirs: src
c-sources: ffi_init.c
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
, teststack
, containers
, text
, data-msgpack
, bytestring
, time
, Decimal
, vector
, parallel
, hashable
, data-msgpack
, string-conversions
, binary
, bytestring
, haxl
, aeson
, scientific
, network-msgpack-rpc
, boxes
, mtl
, resource-pool
, monad-logger
, resourcet
, singletons
, ghc-prim
, exceptions
, unordered-containers
, fgl
, regex-pcre
, postgresql-simple
, postgresql-libpq
, async
, formatting
, QuickCheck
, quickcheck-instances
, vector-algorithms
, mmorph
, fast-logger
default-extensions: OverloadedStrings, PackageImports, StandaloneDeriving, GADTs,
TypeFamilies, FlexibleInstances, MultiParamTypeClasses, DeriveGeneric,
DataKinds, TypeOperators, FlexibleContexts, RankNTypes, PolyKinds,
ScopedTypeVariables, DeriveGeneric, GeneralizedNewtypeDeriving
I have the same issue with a simple ghc build using arch :
echo 'main = putStrLn "toto"' > test.hs && ghc test.hs
result
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
/usr/bin/ld.gold: error: test.o: requires unsupported dynamic reloc 11; recompile with -fPIC
/usr/bin/ld.gold: error: /usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/base-4.10.1.0/libHSbase-4.10.1.0.a(Base.o): requires unsupported dynamic reloc 11; recompile with -fPIC
/usr/bin/ld.gold: error: /usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/base-4.10.1.0/libHSbase-4.10.1.0.a(Base.o): requires unsupported dynamic reloc 11; recompile with -fPIC
...
I'm seeing the same sort of requires unsupported dynamic reloc 11; recompile with -fPIC
errors on Alpine Linux (the alpine:latest
docker image to be more precise)
General summary/comments (optional)
This is likely related to #3518 and #3409 etc. But while users seem to have resolved those issues for GHC 8.2.2 and up, I see the same (or a similar) issue when using the --profile flag. Building without --profile works fine.
Steps to reproduce
stack build --profile --system-ghc
(with Archghc-static
package) orstack build --profile
Expected
The project should build without errors and with profiling data.
Actual
Linking fails with thousands of errors like these:
Stack version
I have tried both 1.6.3 and the latest git master.
Method of installation
I have tried:
stack
andstack-bin
packagesI have also tried various builds of GHC 8.2.2 (stack installed builds with ghc-build and tinfo6; as well as the
ghc
andghc-static
builds from the Arch packages). All exhibit this problem.