jank icon indicating copy to clipboard operation
jank copied to clipboard

Reported build failure with double-conversion and openssl on macOS

Open jeaye opened this issue 1 year ago • 3 comments

A user in Slack reported macOS build failures for jank, after running ./bin/compile:

jank/compiler+runtime/third-party/folly/folly/Conv.h:124:10: fatal error: 'double-conversion/double-conversion.h' file not found
jank/compiler+runtime/src/cpp/jank/util/sha256.cpp:3:10: fatal error: 'openssl/sha.h' file not found

The user had double-conversion and openssl installed via homebrew. I suspect that we need to find these packages via cmake. This wasn't a problem before, since we used vcpkg to build folly, but now that we build it as part of jank's compilation, we'll need to meet its dependencies.

I suspect this hasn't been an issue on Linux, since those headers are standard places. Homebrew puts them somewhere non-standard.

This should be a reasonably straight-forward CMake change for anyone on macOS.

jeaye avatar Aug 17 '24 17:08 jeaye

export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/opt/homebrew/include" helped for the compilation step.

But then it failed on linking with:

Undefined symbols for architecture arm64:
  "_SHA256", referenced from:
      jank::util::sha256(jank::native_persistent_string const&) in libjank.a[4](sha256.cpp.o)
ld: symbol(s) not found for architecture arm64

avitkauskas avatar Aug 17 '24 18:08 avitkauskas

Yep, once the compilation is done, we need to link. CMake will also need to know where to find the correct homebrew libs. Those are likely in /opt/homebrew/lib. Using an environment variable can work here, as a workaround, but it should not be needed. The correct solution is to have CMake handle these libs.

jeaye avatar Aug 17 '24 18:08 jeaye

I see that homebrew lib directory is included in the liker options, but still it fails to find the _SHA256 symbol:

[1/3] Linking CXX executable jank FAILED: jank : && /Users/alvis/jank/compiler+runtime/build/llvm-install/usr/local/bin/clang++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/opt/homebrew/opt/llvm/lib -L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/lib CMakeFiles/jank_exe.dir/src/cpp/main.cpp.o -o jank [...]

avitkauskas avatar Aug 17 '24 19:08 avitkauskas

Just in case if it helps, I succeeded to build jank with the following "hacks" before running the configure command: ./bin/configure -GNinja -DCMAKE_BUILD_TYPE=Release

export CPLUS_INCLUDE_PATH=/opt/homebrew/include eliminated the problem of not able to find 'openssl/sha.h' and other header files. export LDFLAGS=/opt/homebrew/lib/libcrypto.a eliminated the error of Undefined symbol for architecture arm64: "_SHA256" It has nothing to do with the linker flags itself, but it let the configure process to include the libcrypto.a into the list of libs and then the link step succeeded. Using the -L flag did not help. export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) that set SDKROOT to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk and let to successfully build the .pch file that was failing without it.

Unfortunately, I do not know the C building system good enough to fix it properly.

avitkauskas avatar Aug 28 '24 07:08 avitkauskas

I'm on a M1 Mac OS and following the instructions above I got the following error. Does that mean we cannot compile on M1 yet, or is it simply a config issue?

export CC=$PWD/build/llvm-install/usr/local/bin/clang; export CXX=$PWD/build/llvm-install/usr/local/bin/clang++
export CPLUS_INCLUDE_PATH=/opt/homebrew/include; export LDFLAGS=/opt/homebrew/lib/libcrypto.a
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)

error:

❯ ./bin/compile
[74/85] Linking CXX executable jank
FAILED: jank
: && $HOME/personal/jank/compiler+runtime/build/llvm-install/usr/local/bin/clang++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/jank_exe.dir/src/cpp/main.cpp.o -o jank  -Wl,-force_load  libjank.a  -Wl,-force_load  libnanobench.a  libfolly.a  vcpkg_installed/x64-clang-static/lib/libfmt.a  vcpkg_installed/x64-clang-static/lib/libboost_filesystem.a  vcpkg_installed/x64-clang-static/lib/libboost_system.a  llvm-install/usr/local/lib/libLLVMAArch64CodeGen.a  llvm-install/usr/local/lib/libLLVMAArch64AsmParser.a  llvm-install/usr/local/lib/libLLVMAArch64Desc.a  llvm-install/usr/local/lib/libLLVMAArch64Disassembler.a  llvm-install/usr/local/lib/libLLVMAArch64Info.a  llvm-install/usr/local/lib/libLLVMAArch64Utils.a  llvm-install/usr/local/lib/libLLVMSupport.a  llvm-install/usr/local/lib/libLLVMLineEditor.a  llvm-install/usr/local/lib/libLLVMOrcJIT.a  llvm-install/usr/local/lib/libLLVMCore.a  llvm-install/usr/local/lib/libLLVMAArch64CodeGen.a  llvm-install/usr/local/lib/libLLVMAArch64AsmParser.a  llvm-install/usr/local/lib/libLLVMAArch64Desc.a  llvm-install/usr/local/lib/libLLVMAArch64Disassembler.a  llvm-install/usr/local/lib/libLLVMAArch64Info.a  llvm-install/usr/local/lib/libLLVMAArch64Utils.a  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd  vcpkg_installed/x64-clang-static/lib/libcord.a  vcpkg_installed/x64-clang-static/lib/libgccpp.a  vcpkg_installed/x64-clang-static/lib/libgctba.a  vcpkg_installed/x64-clang-static/lib/libgc.a  vcpkg_installed/x64-clang-static/lib/libzippp_static.a  vcpkg_installed/x64-clang-static/lib/libzip.a  vcpkg_installed/x64-clang-static/lib/libbz2.a  vcpkg_installed/x64-clang-static/lib/libCLI11.a  -lreadline  llvm-install/usr/local/lib/libclangInterpreter.a  llvm-install/usr/local/lib/libLLVMAArch64CodeGen.a  llvm-install/usr/local/lib/libLLVMAsmPrinter.a  llvm-install/usr/local/lib/libLLVMGlobalISel.a  llvm-install/usr/local/lib/libLLVMSelectionDAG.a  llvm-install/usr/local/lib/libLLVMAArch64AsmParser.a  llvm-install/usr/local/lib/libLLVMAArch64Disassembler.a  llvm-install/usr/local/lib/libLLVMAArch64Desc.a  llvm-install/usr/local/lib/libLLVMMCDisassembler.a  llvm-install/usr/local/lib/libLLVMAArch64Info.a  llvm-install/usr/local/lib/libLLVMAArch64Utils.a  llvm-install/usr/local/lib/libclangFrontendTool.a  llvm-install/usr/local/lib/libclangCodeGen.a  llvm-install/usr/local/lib/libLLVMCoverage.a  llvm-install/usr/local/lib/libLLVMFrontendDriver.a  llvm-install/usr/local/lib/libLLVMLTO.a  llvm-install/usr/local/lib/libLLVMExtensions.a  llvm-install/usr/local/lib/libclangExtractAPI.a  llvm-install/usr/local/lib/libclangInstallAPI.a  llvm-install/usr/local/lib/libLLVMTextAPIBinaryReader.a  llvm-install/usr/local/lib/libclangRewriteFrontend.a  llvm-install/usr/local/lib/libclangARCMigrate.a  llvm-install/usr/local/lib/libclangStaticAnalyzerFrontend.a  llvm-install/usr/local/lib/libclangStaticAnalyzerCheckers.a  llvm-install/usr/local/lib/libclangStaticAnalyzerCore.a  llvm-install/usr/local/lib/libclangCrossTU.a  llvm-install/usr/local/lib/libclangIndex.a  llvm-install/usr/local/lib/libclangFrontend.a  llvm-install/usr/local/lib/libclangDriver.a  llvm-install/usr/local/lib/libclangFormat.a  llvm-install/usr/local/lib/libclangToolingInclusions.a  llvm-install/usr/local/lib/libclangToolingCore.a  llvm-install/usr/local/lib/libclangRewrite.a  llvm-install/usr/local/lib/libclangParse.a  llvm-install/usr/local/lib/libclangSerialization.a  llvm-install/usr/local/lib/libclangSema.a  llvm-install/usr/local/lib/libclangAnalysis.a  llvm-install/usr/local/lib/libclangASTMatchers.a  llvm-install/usr/local/lib/libLLVMFrontendHLSL.a  llvm-install/usr/local/lib/libclangAPINotes.a  llvm-install/usr/local/lib/libclangEdit.a  llvm-install/usr/local/lib/libclangAST.a  llvm-install/usr/local/lib/libclangLex.a  llvm-install/usr/local/lib/libclangBasic.a  llvm-install/usr/local/lib/libclangSupport.a  llvm-install/usr/local/lib/libLLVMOrcDebugging.a  llvm-install/usr/local/lib/libLLVMOrcJIT.a  llvm-install/usr/local/lib/libLLVMPasses.a  llvm-install/usr/local/lib/libLLVMCFGuard.a  llvm-install/usr/local/lib/libLLVMCodeGen.a  llvm-install/usr/local/lib/libLLVMCodeGenTypes.a  llvm-install/usr/local/lib/libLLVMObjCARCOpts.a  llvm-install/usr/local/lib/libLLVMCoroutines.a  llvm-install/usr/local/lib/libLLVMHipStdPar.a  llvm-install/usr/local/lib/libLLVMipo.a  llvm-install/usr/local/lib/libLLVMVectorize.a  llvm-install/usr/local/lib/libLLVMBitWriter.a  llvm-install/usr/local/lib/libLLVMFrontendOpenMP.a  llvm-install/usr/local/lib/libLLVMScalarOpts.a  llvm-install/usr/local/lib/libLLVMAggressiveInstCombine.a  llvm-install/usr/local/lib/libLLVMInstCombine.a  llvm-install/usr/local/lib/libLLVMFrontendOffloading.a  llvm-install/usr/local/lib/libLLVMLinker.a  llvm-install/usr/local/lib/libLLVMIRPrinter.a  llvm-install/usr/local/lib/libLLVMInstrumentation.a  llvm-install/usr/local/lib/libLLVMTransformUtils.a  llvm-install/usr/local/lib/libLLVMExecutionEngine.a  llvm-install/usr/local/lib/libLLVMTarget.a  llvm-install/usr/local/lib/libLLVMAnalysis.a  llvm-install/usr/local/lib/libLLVMProfileData.a  llvm-install/usr/local/lib/libLLVMSymbolize.a  llvm-install/usr/local/lib/libLLVMDebugInfoPDB.a  llvm-install/usr/local/lib/libLLVMDebugInfoMSF.a  llvm-install/usr/local/lib/libLLVMDebugInfoBTF.a  llvm-install/usr/local/lib/libLLVMWindowsDriver.a  llvm-install/usr/local/lib/libLLVMRuntimeDyld.a  llvm-install/usr/local/lib/libLLVMJITLink.a  llvm-install/usr/local/lib/libLLVMOrcTargetProcess.a  llvm-install/usr/local/lib/libLLVMOption.a  llvm-install/usr/local/lib/libLLVMOrcShared.a  llvm-install/usr/local/lib/libLLVMDebugInfoDWARF.a  llvm-install/usr/local/lib/libLLVMObject.a  llvm-install/usr/local/lib/libLLVMMCParser.a  llvm-install/usr/local/lib/libLLVMMC.a  llvm-install/usr/local/lib/libLLVMDebugInfoCodeView.a  llvm-install/usr/local/lib/libLLVMIRReader.a  llvm-install/usr/local/lib/libLLVMBitReader.a  llvm-install/usr/local/lib/libLLVMAsmParser.a  llvm-install/usr/local/lib/libLLVMCore.a  llvm-install/usr/local/lib/libLLVMRemarks.a  llvm-install/usr/local/lib/libLLVMBitstreamReader.a  llvm-install/usr/local/lib/libLLVMTextAPI.a  llvm-install/usr/local/lib/libLLVMBinaryFormat.a  llvm-install/usr/local/lib/libLLVMTargetParser.a  llvm-install/usr/local/lib/libLLVMSupport.a  -lm  vcpkg_installed/x64-clang-static/lib/libz.a  llvm-install/usr/local/lib/libLLVMDemangle.a  vcpkg_installed/x64-clang-static/lib/libboost_atomic.a && :
ld: warning: text-based stub file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd and library file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd are out of sync. Falling back to library file for linking.
Undefined symbols for architecture arm64:
  "_SHA256", referenced from:
      jank::util::sha256(jank::native_persistent_string const&) in libjank.a(sha256.cpp.o)
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

jianlingzhong avatar Oct 03 '24 19:10 jianlingzhong

I'm on a M1 Mac OS and following the instructions above I got the following error. Does that mean we cannot compile on M1 yet, or is it simply a config issue?

export CC=$PWD/build/llvm-install/usr/local/bin/clang; export CXX=$PWD/build/llvm-install/usr/local/bin/clang++
export CPLUS_INCLUDE_PATH=/opt/homebrew/include; export LDFLAGS=/opt/homebrew/lib/libcrypto.a
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)

error:

❯ ./bin/compile
[74/85] Linking CXX executable jank
FAILED: jank
: && $HOME/personal/jank/compiler+runtime/build/llvm-install/usr/local/bin/clang++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/jank_exe.dir/src/cpp/main.cpp.o -o jank  -Wl,-force_load  libjank.a  -Wl,-force_load  libnanobench.a  libfolly.a  vcpkg_installed/x64-clang-static/lib/libfmt.a  vcpkg_installed/x64-clang-static/lib/libboost_filesystem.a  vcpkg_installed/x64-clang-static/lib/libboost_system.a  llvm-install/usr/local/lib/libLLVMAArch64CodeGen.a  llvm-install/usr/local/lib/libLLVMAArch64AsmParser.a  llvm-install/usr/local/lib/libLLVMAArch64Desc.a  llvm-install/usr/local/lib/libLLVMAArch64Disassembler.a  llvm-install/usr/local/lib/libLLVMAArch64Info.a  llvm-install/usr/local/lib/libLLVMAArch64Utils.a  llvm-install/usr/local/lib/libLLVMSupport.a  llvm-install/usr/local/lib/libLLVMLineEditor.a  llvm-install/usr/local/lib/libLLVMOrcJIT.a  llvm-install/usr/local/lib/libLLVMCore.a  llvm-install/usr/local/lib/libLLVMAArch64CodeGen.a  llvm-install/usr/local/lib/libLLVMAArch64AsmParser.a  llvm-install/usr/local/lib/libLLVMAArch64Desc.a  llvm-install/usr/local/lib/libLLVMAArch64Disassembler.a  llvm-install/usr/local/lib/libLLVMAArch64Info.a  llvm-install/usr/local/lib/libLLVMAArch64Utils.a  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd  vcpkg_installed/x64-clang-static/lib/libcord.a  vcpkg_installed/x64-clang-static/lib/libgccpp.a  vcpkg_installed/x64-clang-static/lib/libgctba.a  vcpkg_installed/x64-clang-static/lib/libgc.a  vcpkg_installed/x64-clang-static/lib/libzippp_static.a  vcpkg_installed/x64-clang-static/lib/libzip.a  vcpkg_installed/x64-clang-static/lib/libbz2.a  vcpkg_installed/x64-clang-static/lib/libCLI11.a  -lreadline  llvm-install/usr/local/lib/libclangInterpreter.a  llvm-install/usr/local/lib/libLLVMAArch64CodeGen.a  llvm-install/usr/local/lib/libLLVMAsmPrinter.a  llvm-install/usr/local/lib/libLLVMGlobalISel.a  llvm-install/usr/local/lib/libLLVMSelectionDAG.a  llvm-install/usr/local/lib/libLLVMAArch64AsmParser.a  llvm-install/usr/local/lib/libLLVMAArch64Disassembler.a  llvm-install/usr/local/lib/libLLVMAArch64Desc.a  llvm-install/usr/local/lib/libLLVMMCDisassembler.a  llvm-install/usr/local/lib/libLLVMAArch64Info.a  llvm-install/usr/local/lib/libLLVMAArch64Utils.a  llvm-install/usr/local/lib/libclangFrontendTool.a  llvm-install/usr/local/lib/libclangCodeGen.a  llvm-install/usr/local/lib/libLLVMCoverage.a  llvm-install/usr/local/lib/libLLVMFrontendDriver.a  llvm-install/usr/local/lib/libLLVMLTO.a  llvm-install/usr/local/lib/libLLVMExtensions.a  llvm-install/usr/local/lib/libclangExtractAPI.a  llvm-install/usr/local/lib/libclangInstallAPI.a  llvm-install/usr/local/lib/libLLVMTextAPIBinaryReader.a  llvm-install/usr/local/lib/libclangRewriteFrontend.a  llvm-install/usr/local/lib/libclangARCMigrate.a  llvm-install/usr/local/lib/libclangStaticAnalyzerFrontend.a  llvm-install/usr/local/lib/libclangStaticAnalyzerCheckers.a  llvm-install/usr/local/lib/libclangStaticAnalyzerCore.a  llvm-install/usr/local/lib/libclangCrossTU.a  llvm-install/usr/local/lib/libclangIndex.a  llvm-install/usr/local/lib/libclangFrontend.a  llvm-install/usr/local/lib/libclangDriver.a  llvm-install/usr/local/lib/libclangFormat.a  llvm-install/usr/local/lib/libclangToolingInclusions.a  llvm-install/usr/local/lib/libclangToolingCore.a  llvm-install/usr/local/lib/libclangRewrite.a  llvm-install/usr/local/lib/libclangParse.a  llvm-install/usr/local/lib/libclangSerialization.a  llvm-install/usr/local/lib/libclangSema.a  llvm-install/usr/local/lib/libclangAnalysis.a  llvm-install/usr/local/lib/libclangASTMatchers.a  llvm-install/usr/local/lib/libLLVMFrontendHLSL.a  llvm-install/usr/local/lib/libclangAPINotes.a  llvm-install/usr/local/lib/libclangEdit.a  llvm-install/usr/local/lib/libclangAST.a  llvm-install/usr/local/lib/libclangLex.a  llvm-install/usr/local/lib/libclangBasic.a  llvm-install/usr/local/lib/libclangSupport.a  llvm-install/usr/local/lib/libLLVMOrcDebugging.a  llvm-install/usr/local/lib/libLLVMOrcJIT.a  llvm-install/usr/local/lib/libLLVMPasses.a  llvm-install/usr/local/lib/libLLVMCFGuard.a  llvm-install/usr/local/lib/libLLVMCodeGen.a  llvm-install/usr/local/lib/libLLVMCodeGenTypes.a  llvm-install/usr/local/lib/libLLVMObjCARCOpts.a  llvm-install/usr/local/lib/libLLVMCoroutines.a  llvm-install/usr/local/lib/libLLVMHipStdPar.a  llvm-install/usr/local/lib/libLLVMipo.a  llvm-install/usr/local/lib/libLLVMVectorize.a  llvm-install/usr/local/lib/libLLVMBitWriter.a  llvm-install/usr/local/lib/libLLVMFrontendOpenMP.a  llvm-install/usr/local/lib/libLLVMScalarOpts.a  llvm-install/usr/local/lib/libLLVMAggressiveInstCombine.a  llvm-install/usr/local/lib/libLLVMInstCombine.a  llvm-install/usr/local/lib/libLLVMFrontendOffloading.a  llvm-install/usr/local/lib/libLLVMLinker.a  llvm-install/usr/local/lib/libLLVMIRPrinter.a  llvm-install/usr/local/lib/libLLVMInstrumentation.a  llvm-install/usr/local/lib/libLLVMTransformUtils.a  llvm-install/usr/local/lib/libLLVMExecutionEngine.a  llvm-install/usr/local/lib/libLLVMTarget.a  llvm-install/usr/local/lib/libLLVMAnalysis.a  llvm-install/usr/local/lib/libLLVMProfileData.a  llvm-install/usr/local/lib/libLLVMSymbolize.a  llvm-install/usr/local/lib/libLLVMDebugInfoPDB.a  llvm-install/usr/local/lib/libLLVMDebugInfoMSF.a  llvm-install/usr/local/lib/libLLVMDebugInfoBTF.a  llvm-install/usr/local/lib/libLLVMWindowsDriver.a  llvm-install/usr/local/lib/libLLVMRuntimeDyld.a  llvm-install/usr/local/lib/libLLVMJITLink.a  llvm-install/usr/local/lib/libLLVMOrcTargetProcess.a  llvm-install/usr/local/lib/libLLVMOption.a  llvm-install/usr/local/lib/libLLVMOrcShared.a  llvm-install/usr/local/lib/libLLVMDebugInfoDWARF.a  llvm-install/usr/local/lib/libLLVMObject.a  llvm-install/usr/local/lib/libLLVMMCParser.a  llvm-install/usr/local/lib/libLLVMMC.a  llvm-install/usr/local/lib/libLLVMDebugInfoCodeView.a  llvm-install/usr/local/lib/libLLVMIRReader.a  llvm-install/usr/local/lib/libLLVMBitReader.a  llvm-install/usr/local/lib/libLLVMAsmParser.a  llvm-install/usr/local/lib/libLLVMCore.a  llvm-install/usr/local/lib/libLLVMRemarks.a  llvm-install/usr/local/lib/libLLVMBitstreamReader.a  llvm-install/usr/local/lib/libLLVMTextAPI.a  llvm-install/usr/local/lib/libLLVMBinaryFormat.a  llvm-install/usr/local/lib/libLLVMTargetParser.a  llvm-install/usr/local/lib/libLLVMSupport.a  -lm  vcpkg_installed/x64-clang-static/lib/libz.a  llvm-install/usr/local/lib/libLLVMDemangle.a  vcpkg_installed/x64-clang-static/lib/libboost_atomic.a && :
ld: warning: text-based stub file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd and library file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd are out of sync. Falling back to library file for linking.
Undefined symbols for architecture arm64:
  "_SHA256", referenced from:
      jank::util::sha256(jank::native_persistent_string const&) in libjank.a(sha256.cpp.o)
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

turns out i need to export those env variables before configure, then everything works.

jianlingzhong avatar Oct 03 '24 19:10 jianlingzhong

Looks like we need these changes to the CMake setup:

  1. On macOS, add -I /opt/homebrew/include to jank_aot_compiler_flags
  2. On macOS, add -L /opt/homebrew/lib to jank_linker_flags
  3. On macOS, add crypto to the link libraries for jank_lib

The SDKROOT var isn't anything we can tackle on our end, I'm guessing. That's specific to each dev's machine. Anyone with a mac open to trying these changes and submitting a PR if they work? I only have x86_64 Linux machines. :open_mouth:

jeaye avatar Oct 03 '24 19:10 jeaye

I am looking into this, and I think I know where to put the first two:

    • CMakeLists.txt line 63
    • CMakeLists.txt line 97

But I do not understand how to do the 3. Can you give a bit more detailed guidlines?

I tried to fix 1. and 2., then did: export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) export LDFLAGS=/opt/homebrew/lib/libcrypto.a (still my hack) and it compiled successfully.

avitkauskas avatar Oct 03 '24 20:10 avitkauskas

I am looking into this, and I think I know where to put the first two:

1. * CMakeLists.txt line 63

2. * CMakeLists.txt line 97

But I do not understand how to do the 3. Can you give a bit more detailed guidlines?

I tried to fix 1. and 2., then did: export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) export LDFLAGS=/opt/homebrew/lib/libcrypto.a (still my hack) and it compiled successfully.

The third item can be done in the expression starting on line 237. We just want to conditionally add crypto there, for macOS. Something like this should work: $<$<PLATFORM_ID:Darwin>crypto>

jeaye avatar Oct 03 '24 20:10 jeaye

Note that we should just use the same generator expression for the first and second items, too. For example, $<$<PLATFORM_ID:Darwin>-I /opt/homebrew/include> for the first item should work.

jeaye avatar Oct 03 '24 21:10 jeaye

I am totally certain that I do not know what I'm doing here ;) but I figured out you missed a colon :) $<$<PLATFORM_ID:Darwin>:crypto> And yes - I confirm this works! The line export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) should be included somewhere in the build instructions, I suppose. I can try to make a PR tomorrow or you can just make changes yourself if it's easier and quicker for you.

avitkauskas avatar Oct 03 '24 21:10 avitkauskas

Also, at the end of compilation I have the following warning. I don't know if this could be fixed somehow or can be safely ignored:

ld: warning: ignoring duplicate libraries: 'llvm-install/usr/local/lib/libLLVMAArch64AsmParser.a', 'llvm-install/usr/local/lib/libLLVMAArch64CodeGen.a', 'llvm-install/usr/local/lib/libLLVMAArch64Desc.a', 'llvm-install/usr/local/lib/libLLVMAArch64Disassembler.a', 'llvm-install/usr/local/lib/libLLVMAArch64Info.a', 'llvm-install/usr/local/lib/libLLVMAArch64Utils.a', 'llvm-install/usr/local/lib/libLLVMCore.a', 'llvm-install/usr/local/lib/libLLVMOrcJIT.a', 'llvm-install/usr/local/lib/libLLVMSupport.a'

avitkauskas avatar Oct 03 '24 21:10 avitkauskas

I am totally certain that I do not know what I'm doing here ;) but I figured out you missed a colon :) $<$<PLATFORM_ID:Darwin>:crypto> And yes - I confirm this works! The line export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) should be included somewhere in the build instructions, I suppose. I can try to make a PR tomorrow or you can just make changes yourself if it's easier and quicker for you.

Ah, good find! Agreed, we can add a note about SDKROOT to the build doc. I'll stand by for your PR, since I'm actively hacking away on other things right now. Thanks for figuring all of this out!

Also, at the end of compilation I have the following warning. I don't know if this could be fixed somehow or can be safely ignored:

Looks like something we can ignore for now.

jeaye avatar Oct 03 '24 21:10 jeaye