tinygo-org / go-llvm

Go bindings to LLVM. Used as part of TinyGo.

Home Page:https://tinygo.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for macOS

turbolent opened this issue · comments

I see that there's a file for Darwin support, but when I try getting this package on macOS, I get these compilation errors.

Is it possible that this package is trying to use Apple's LLVM (installed through Xcode) instead of the Homebrew version?

$ go get github.com/tinygo-org/go-llvm
# github.com/tinygo-org/go-llvm
In file included from IRBindings.cpp:13:
In file included from go/src/github.com/tinygo-org/go-llvm/IRBindings.h:16:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/Core.h:19:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/Types.h:17:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/DataTypes.h:28:
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:313:9: error: no member named 'signbit' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:314:9: error: no member named 'fpclassify' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:315:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: 'finite' declared here
In file included from IRBindings.cpp:13:
In file included from go/src/github.com/tinygo-org/go-llvm/IRBindings.h:16:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/Core.h:19:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/Types.h:17:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/DataTypes.h:28:
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:316:9: error: no member named 'isinf' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:317:9: error: no member named 'isnan' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:318:9: error: no member named 'isnormal' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:319:9: error: no member named 'isgreater' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:320:9: error: no member named 'isgreaterequal' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:321:9: error: no member named 'isless' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:322:9: error: no member named 'islessequal' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:323:9: error: no member named 'islessgreater' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:324:9: error: no member named 'isunordered' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:325:9: error: no member named 'isunordered' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:331:9: error: no member named 'abs' in the global namespace; did you mean 'fabs'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:417:15: note: 'fabs' declared here
In file included from IRBindings.cpp:13:
In file included from go/src/github.com/tinygo-org/go-llvm/IRBindings.h:16:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/Core.h:19:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/Types.h:17:
In file included from /usr/local/Cellar/llvm/9.0.0_1/include/llvm-c/DataTypes.h:28:
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:551:38: error: no template named 'is_floating_point'
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:551:76: error: definition or redeclaration of 'type' cannot name the global scope
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:551:76: error: no member named 'type' in the global namespace
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:551:80: error: expected ';' at end of declaration
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:552:27: error: unknown type name '_A1'
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Info

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.1
$ brew info llvm                                                                                                                                            
llvm: stable 9.0.0 (bottled), HEAD [keg-only]
Next-gen compiler infrastructure
https://llvm.org/
/usr/local/Cellar/llvm/9.0.0_1 (6,839 files, 3.7GB)
  Poured from bottle on 2019-11-06 at 10:12:51
commented

Apple LLVM should be fine, I believe that's what we're using to build the macOS binaries. However, it may be a problem with macOS Catalina.

Can you share the output of the following?

/usr/local/opt/llvm@9/bin/llvm-config --cppflags
/usr/local/opt/llvm@9/bin/llvm-config --ldflags --libs --system-libs all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines debuginfodwarf executionengine instrumentation interpreter ipo irreader linker mc mcjit objcarcopts option profiledata scalaropts support target

And also, can you try export CC=clang-9 CXX=clang++-9, to explicitly use the Homebrew version of LLVM?

Yeah, I guess this is due to changes in Catalina.

Here's the output of the LLVM config program:

$ /usr/local/opt/llvm@9/bin/llvm-config --cppflags

-I/usr/local/Cellar/llvm/9.0.0_1/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
$ /usr/local/opt/llvm@9/bin/llvm-config --ldflags --libs --system-libs all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines debuginfodwarf executionengine instrumentation interpreter ipo irreader linker mc mcjit objcarcopts option profiledata scalaropts support target

-L/usr/local/Cellar/llvm/9.0.0_1/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names
-lLLVMOption -lLLVMObjCARCOpts -lLLVMMCJIT -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCoroutines -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Utils -lLLVMX86Info -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyDesc -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyInfo -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMRISCVDisassembler -lLLVMRISCVCodeGen -lLLVMRISCVAsmParser -lLLVMRISCVDesc -lLLVMRISCVUtils -lLLVMRISCVInfo -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMMSP430Disassembler -lLLVMMSP430CodeGen -lLLVMMSP430AsmParser -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMLanaiDisassembler -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFDisassembler -lLLVMBPFCodeGen -lLLVMBPFAsmParser -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMUtils -lLLVMARMInfo -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMMIRParser -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMAArch64Disassembler -lLLVMMCDisassembler -lLLVMAArch64CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMAArch64AsmParser -lLLVMMCParser -lLLVMAArch64Desc -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBinaryFormat -lLLVMAArch64Utils -lLLVMAArch64Info -lLLVMSupport -lLLVMDemangle
-lz -lcurses -lm -lxml2

With CC CXX set, I still get:

$ go get github.com/tinygo-org/go-llvm
# runtime/cgo
In file included from _cgo_export.c:3:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:134:25: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
...

I think this can be closed now.

This is done.