AdaCore / gnat-llvm

LLVM based GNAT compiler
179 stars 18 forks source link

macOS/llvm 10.0.0 #11

Closed simonjwright closed 4 years ago

simonjwright commented 4 years ago

Just a heads-up: can’t build gnat-llvm 5b1fe09/gcc cc558e2 against GCC 10.1.0 and a binary release of LLVM 10.0.0: e.g.

$ ../../ll/clang+llvm-10.0.0-x86_64-apple-darwin/bin/clang hello.c
ld: unknown option: -platform_version
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

This is on Mojave, Xcode 11.3; might work on Catalina with Xcode 11.4.

ArnaudCharlet commented 4 years ago

Note that what you are showing is a non working clang. My recommendation is to use an= pre-existing clang+llvm build that is known to work, and build GNAT LLVM on top of it, which will work.

simonjwright commented 4 years ago

First, that LLVM 10.0.0 was downloaded from llvm.org. Second, it works just fine (but see below) on Catalina with Xcode 11.4. Third, gnat-llvm won’t build with the downloaded LLVM 9.0.0 (or 9.0.1), which is presumably why you specify 10.0.0:

/Volumes/Miscellaneous/ll/gnat-llvm/llvm-interface/llvm_wrapper.cc:252:10: error: use of undeclared identifier 'encode'
  return encode (dl->getStackAlignment ());
         ^
/Volumes/Miscellaneous/ll/gnat-llvm/llvm-interface/llvm_wrapper.cc:330:34: error: use of undeclared identifier 'MaybeAlign'
  return bld->CreateMemCpy (Dst, MaybeAlign (DstAlign), Src,
                                 ^
[...]
6 errors generated.

Fourth, on Catalina, 'make gnatlib` fails with

clang -c -O2 -g -DIN_RTS=1 -fexceptions -gdwarf-aranges -DSTANDALONE  -I../adainclude -I../include ../adainclude/thread.c
../adainclude/thread.c:59:10: fatal error: 'mach/mach.h' file not found
#include <mach/mach.h>
         ^~~~~~~~~~~~~
1 error generated.

which is fixed, resulting in a successful build!!!, by swearing at Apple and setting

EXTRALIBFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

As I said, this is a heads-up, nothing you can do (except perhaps reference these notes somewhere?)

ArnaudCharlet commented 4 years ago

Thanks, I misunderstood the goal of your report, so this is noted. I'm sure others will appreciate your experience return!

simonjwright commented 4 years ago

After much frustration, it turns out that the way to work round the missing includes is simply to define SDKROOT:

export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
make build

Or, if you only have the CommandLineTools,

export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
make build