Opened 6 months ago

Closed 3 months ago

#8497 closed bug (fixed)

clang/wrapper cannot build GHC head with integer-gmp on Mavericks

Reported by: kazu-yamamoto Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.7
Keywords: clang Cc: george.colpitts@…
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: Building GHC failed Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I'm using GHC 7.6.3 with clang/wrapper (setting is modified). This GHC cannot build GHC head with integer-gmp:

checking for assembler byte directive... .byte
checking how to define a 32-bit word... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: can't open file: conftest.o (No such file or directory)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: can't open file: conftest.o (No such file or directory)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: can't open file: conftest.o (No such file or directory)
configure: error: cannot determine how to define a 32-bit word
make[1]: *** [libraries/integer-gmp/gmp/gmp.h] Error 1
make: *** [all] Error 2

With integer-simple, build is OK.

For more information, please see http://d.hatena.ne.jp/kazu-yamamoto/20131028/1382921924

Attachments (2)

config.log (10.7 KB) - added by kazu-yamamoto 6 months ago.
ghc-mk-for-clang.patch (869 bytes) - added by kazu-yamamoto 5 months ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 6 months ago by hvr

could you please attach the resulting libraries/integer-gmp/config.log log file to this ticket?

Changed 6 months ago by kazu-yamamoto

comment:2 Changed 6 months ago by kazu-yamamoto

Attached.

comment:3 Changed 6 months ago by hvr

Ah, now I see.. that error is generated by the GMP source code included in the tarball; could you try installing a GMP library (or is that called Framework in OSX?) in your Xcode environment, so GHC doesn't have to compile its own GMP library?

comment:4 Changed 6 months ago by kazu-yamamoto

I installed GMP by MacPorts? and did:

% ./configure --prefix=/ghc-head --with-gmp-includes=/opt/local/include --with-gmp-libraries=/opt/local/lib
% make

I got the following error this time:

inplace/bin/dll-split compiler/stage2/build/.depend-v-p-dyn.haskell "DynFlags" "
Annotations Avail Bag BasicTypes BinIface Binary Bitmap BlockId BooleanFormula B
reakArray BufWrite BuildTyCl ByteCodeAsm ByteCodeInstr ByteCodeItbls CLabel Clas
s CmdLineParser Cmm CmmCallConv CmmExpr CmmInfo CmmMachOp CmmNode CmmType CmmUti
ls CoAxiom CodeGen.Platform CodeGen.Platform.ARM CodeGen.Platform.NoRegs CodeGen
.Platform.PPC CodeGen.Platform.PPC_Darwin CodeGen.Platform.SPARC CodeGen.Platfor
m.X86 CodeGen.Platform.X86_64 Coercion Config Constants CoreArity CoreFVs CoreLi
nt CoreSubst CoreSyn CoreTidy CoreUnfold CoreUtils CostCentre DataCon Demand Dig
raph DriverPhases DsMonad DynFlags Encoding ErrUtils Exception ExtsCompat46 FamI
nst FamInstEnv FastBool FastFunctions FastMutInt FastString FastTypes Finder Fin
gerprint FiniteMap ForeignCall Hooks Hoopl Hoopl.Dataflow HsBinds HsDecls HsDoc 
HsExpr HsImpExp HsLit HsPat HsSyn HsTypes HsUtils HscTypes IOEnv Id IdInfo Iface
Env IfaceSyn IfaceType InstEnv InteractiveEvalTypes Kind ListSetOps Literal Load
Iface Maybes MkCore MkGraph MkId Module MonadUtils Name NameEnv NameSet OccName 
OccurAnal OptCoercion OrdList Outputable PackageConfig Packages Pair Panic Pipel
ineMonad Platform PlatformConstants PprCmm PprCmmDecl PprCmmExpr PprCore PrelInf
o PrelNames PrelRules Pretty PrimOp RdrName Reg RegClass Rules SMRep Serialized 
SrcLoc StaticFlags StgCmmArgRep StgCmmClosure StgCmmEnv StgCmmLayout StgCmmMonad
 StgCmmProf StgCmmTicky StgCmmUtils StgSyn Stream StringBuffer TcEvidence TcIfac
e TcMType TcRnMonad TcRnTypes TcType TcTypeNats TrieMap TyCon Type TypeRep TysPr
im TysWiredIn Unify UniqFM UniqSet UniqSupply Unique Util Var VarEnv VarSet"
dyld: lazy symbol binding failed: Symbol not found: _locale_charset
  Referenced from: /Users/kazu/work/ghc/libraries/base/dist-install/build/libHSb
ase-4.7.0.0-ghc7.7.20131102.dylib
  Expected in: flat namespace

dyld: Symbol not found: _locale_charset
  Referenced from: /Users/kazu/work/ghc/libraries/base/dist-install/build/libHSb
ase-4.7.0.0-ghc7.7.20131102.dylib
  Expected in: flat namespace

make[1]: *** [compiler/stage2/dll-split.stamp] Trace/BPT trap: 5
make: *** [all] Error 2

comment:5 Changed 6 months ago by kazu-yamamoto

My GMP is version 5.1.2.

comment:6 Changed 6 months ago by kazu-yamamoto

_locale_charset is a libiconv issue. It's very strange that --with-gmp-xxx influences iconv.

Anyway, I tried:

% ./configure --prefix=/ghc-head --with-gmp-includes=/opt/local/include --with-gmp-libraries=/opt/local/lib --with-iconv-includes=/usr/include --with-iconv-libraries=/usr/lib

But this time, the version of FFI mismatched. So, I did:

% ./configure --prefix=/ghc-head --with-gmp-includes=/opt/local/include --with-gmp-libraries=/opt/local/lib --with-iconv-includes=/usr/include --with-iconv-libraries=/usr/lib --with-system-libffi --with-ffi-includes=/usr/include/ffi --with-ffi-libraries=/usr/lib

This configuration can build GHC head on Mavericks.

comment:7 Changed 5 months ago by kazu-yamamoto

OK. I understand the source of this problem.

On Mavericks, "/usr/bin/gcc" is a wrapper for clang:

% /usr/bin/gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

With this gcc, "libraries/integer-gmp/gmp/gmpbuild/configure" fails.
If we can pass CC=clang to this configure, it works.

To prove this, I modified "libraries/integer-gmp/gmp/ghc.mk" to hard-code "CC=clang". With this hack, I can build GHC head with integer-gmp on Mavericks.

Changed 5 months ago by kazu-yamamoto

comment:8 Changed 5 months ago by kazu-yamamoto

"ghc-mk-for-clang.patch" solves this problem. This patch checks if "gcc" is real "gcc" or "clang". If "gcc" is "clang", CC=clang is specified to configure.

comment:9 Changed 4 months ago by kazu-yamamoto

May I ask to merge this patch before GHC 7.8.1?

comment:10 Changed 3 months ago by George

  • Cc george.colpitts@… added

comment:11 Changed 3 months ago by Austin Seipp <austin@…>

In d2e957dac5738cc694e2c6cab7f56c2b486ed1a4/integer-gmp:

Fix in-tree GMP build (#8497) on OS X Mavericks

Signed-off-by: Austin Seipp <austin@well-typed.com>

comment:12 Changed 3 months ago by thoughtpolice

  • Resolution set to fixed
  • Status changed from new to closed

I used Homebrew to install a 64bit GMP, tested that built on Mavericks, then uninstalled it and applied your patch, and the in-tree build worked fine too.

Merged - thank you Kazu!

Note: See TracTickets for help on using tickets.