Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build LLVM on Linux from Official Release Tarball. #1735

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

flying-dude
Copy link
Contributor

For building llvm, this will download the official release tarball and verify the download.

Previously, it was just cloning the git repo at the release tag. And then proceeded without verifying the download.

@Green-Sky
Copy link
Contributor

did not verify, but this is the way its supposed to be done.

@mingodad
Copy link

mingodad commented Oct 14, 2022

Also I found a simpler/faster way to build on linux with standard clang-llvm-13 binaries see here #1738 (comment)

@flying-dude
Copy link
Contributor Author

@mingodad: i modified my master branch to use distro llvm for building beef.

have only tried on arch linux tho. feel free to add build instructions for ubuntu, if this is relevant for you.

chances are, you gotta set a different CMAKE_PREFIX_PATH to have cmake find the right llvm version on ubuntu.

@mingodad
Copy link

Hello @flying-dude I don't see that you have added any conditional macro on the source files that reference llvm private API nor have removed then from the build.

IDEHelper/LinuxDebugger.cpp
IDEHelper/Targets.cpp
IDEHelper/X64.cpp
IDEHelper/X86.cpp

Also I didn't found any mention to the missing -lffi :

------------------------------ IDE/src/IDEApp.bf ------------------------------
index ae5a0c64..e2e20b92 100644
@@ -10194,7 +10194,7 @@ namespace IDE
 										newString.AppendF("./{} -Wl,-rpath -Wl,@executable_path", rtName);
 									case .iOS:
 									case .Linux:
-										newString.AppendF("./{} -lpthread -ldl -Wl,-rpath -Wl,$ORIGIN", rtName);
+										newString.AppendF("./{} -lpthread -ldl -lffi -Wl,-rpath -Wl,$ORIGIN", rtName);
 									case .Wasm:
 										newString.Append("\"");
 										newString.Append(mInstallDir);

--------------------------- IDEHelper/CMakeLists.txt ---------------------------
index dc41ea2d..8b0cd4e2 100644
@@ -294,7 +294,7 @@ endif()
 if(MSVC)
   target_link_libraries(${PROJECT_NAME} BeefySysLib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib LLVMX86Disassembler.lib LLVMMCDisassembler.lib LLVMSupport.lib LLVMX86Info.lib LLVMX86Desc.lib %(AdditionalDependencies) LLVMMC.lib LLVMObject.lib LLVMCore.lib LLVMBitReader.lib LLVMAsmParser.lib LLVMMCParser.lib LLVMCodeGen.lib LLVMTarget.lib LLVMX86CodeGen.lib LLVMScalarOpts.lib LLVMInstCombine.lib LLVMSelectionDAG.lib LLVMProfileData.lib LLVMTransformUtils.lib LLVMAnalysis.lib LLVMX86AsmParser.lib LLVMAsmPrinter.lib LLVMBitWriter.lib LLVMVectorize.lib LLVMipo.lib LLVMInstrumentation.lib LLVMDebugInfoDWARF.lib LLVMDebugInfoPDB.lib LLVMDebugInfoCodeView.lib LLVMGlobalISel.lib LLVMBinaryFormat.lib LLVMAggressiveInstCombine.lib libcurl_a.lib)
 else()
-  target_link_libraries(${PROJECT_NAME} BeefySysLib hunspell pthread dl ${TARGET_LIBS_OS}
+  target_link_libraries(${PROJECT_NAME} BeefySysLib hunspell pthread ffi dl ${TARGET_LIBS_OS}
 
   )
 endif()

--------------------------------- bin/build.sh ---------------------------------
index 3d234bed..68f8be20 100755
@@ -69,7 +69,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
 	LINKOPTS="-Wl,-no_compact_unwind -Wl,-rpath -Wl,@executable_path"
 else
 	LIBEXT=so
-	LINKOPTS="-ldl -lpthread -Wl,-rpath -Wl,\$ORIGIN"
+	LINKOPTS="-ldl -lpthread -lffi -Wl,-rpath -Wl,\$ORIGIN"
 fi
 
 ln -s -f $ROOTPATH/jbuild_d/Debug/bin/libBeefRT_d.a libBeefRT_d.a

@flying-dude
Copy link
Contributor Author

i commented all the manual inclusion of llvm facilities from the cmake files. instead i use cmake feature find_package. the only two subprojects using llvm are BeefBoot and IDEHelper. the other ones don't use llvm.

for libffi i didn't do any changes. it's just done the same way how upstream does it, which is to compile manually. see here.

i did deactivate the custom backend. everything still works but it will always use llvm. the macros for deactivating the custom backend are here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants