mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Linux updates for LLVM
This commit is contained in:
parent
d5b0e6d06d
commit
c5dee2f8bc
7 changed files with 89 additions and 58 deletions
|
@ -185,29 +185,29 @@ else()
|
||||||
X86Target.cpp
|
X86Target.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(h
|
||||||
../extern/llvm-project_13_0_1/llvm/include
|
../extern/llvm-project_18_1_4/llvm/include
|
||||||
../extern/llvm-project_13_0_1/llvm/lib/Target
|
../extern/llvm-project_18_1_4/llvm/lib/Target18_1_4
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
include_directories(
|
include_directories(
|
||||||
../extern/llvm_linux_13_0_1/include
|
../extern/llvm_linux_18_1_4/include
|
||||||
../extern/llvm_linux_13_0_1/lib/Target/X86
|
../extern/llvm_linux_18_1_4/lib/Target/X86
|
||||||
../extern/llvm_linux_13_0_1/lib/Target/AArch64
|
../extern/llvm_linux_18_1_4/lib/Target/AArch64
|
||||||
)
|
)
|
||||||
set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_13_0_1/lib")
|
set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_18_1_4/lib")
|
||||||
else()
|
else()
|
||||||
include_directories(
|
include_directories(
|
||||||
../extern/llvm_linux_rel_13_0_1/include
|
../extern/llvm_linux_rel_18_1_4/include
|
||||||
../extern/llvm_linux_rel_13_0_1/lib/Target/X86
|
../extern/llvm_linux_rel_18_1_4/lib/Target/X86
|
||||||
../extern/llvm_linux_rel_13_0_1/lib/Target/AArch64
|
../extern/llvm_linux_rel_18_1_4/lib/Target/AArch64
|
||||||
)
|
)
|
||||||
set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_rel_13_0_1/lib")
|
set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_rel_18_1_4/lib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_13_0_1/bin/llvm-config --system-libs --link-static
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_18_1_4/bin/llvm-config --system-libs --link-static
|
||||||
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
|
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
RESULT_VARIABLE EXEC_RESULT
|
RESULT_VARIABLE EXEC_RESULT
|
||||||
|
@ -221,7 +221,7 @@ else()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Found LLVM 13.0.1 (local build)")
|
message(STATUS "Found LLVM 18.1.4 (local build)")
|
||||||
|
|
||||||
set(TARGET_LIBS_OS "${LLVM_SYSTEM_LIBS}")
|
set(TARGET_LIBS_OS "${LLVM_SYSTEM_LIBS}")
|
||||||
|
|
||||||
|
|
|
@ -3284,11 +3284,14 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
|
||||||
case /*S_INLINEES*/0x1168:
|
case /*S_INLINEES*/0x1168:
|
||||||
break;
|
break;
|
||||||
case 0x1176:
|
case 0x1176:
|
||||||
break;
|
|
||||||
case 0x1178:
|
case 0x1178:
|
||||||
break;
|
|
||||||
case 0x1179:
|
case 0x1179:
|
||||||
break;
|
case 0x117A:
|
||||||
|
case 0x117B:
|
||||||
|
case 0x117C:
|
||||||
|
case 0x117D:
|
||||||
|
case 0x117E:
|
||||||
|
case 0x117F:
|
||||||
case 0x1180:
|
case 0x1180:
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
|
|
|
@ -1181,7 +1181,7 @@ void BfIRCodeGen::Read(BfIRTypedValue& typedValue, BfIRCodeGenEntry** codeGenEnt
|
||||||
llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), idx1)};
|
llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), idx1)};
|
||||||
|
|
||||||
auto compositeType = GetTypeMember(target.mTypeEx, 0);
|
auto compositeType = GetTypeMember(target.mTypeEx, 0);
|
||||||
int elemIdx = BF_MIN(idx1, (int)compositeType->mMembers.mSize - 1);
|
int elemIdx = BF_MAX(BF_MIN(idx1, (int)compositeType->mMembers.mSize - 1), 0);
|
||||||
auto elemType = GetTypeMember(compositeType, elemIdx);
|
auto elemType = GetTypeMember(compositeType, elemIdx);
|
||||||
|
|
||||||
auto constant = llvm::dyn_cast<llvm::Constant>(target.mValue);
|
auto constant = llvm::dyn_cast<llvm::Constant>(target.mValue);
|
||||||
|
@ -4709,7 +4709,15 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
{
|
{
|
||||||
CMD_PARAM_NOTRANS(llvm::Value*, instValue);
|
CMD_PARAM_NOTRANS(llvm::Value*, instValue);
|
||||||
BF_ASSERT(llvm::isa<llvm::Instruction>(instValue));
|
BF_ASSERT(llvm::isa<llvm::Instruction>(instValue));
|
||||||
((llvm::Instruction*)instValue)->setDebugLoc(llvm::DebugLoc());
|
|
||||||
|
if (llvm::dyn_cast<llvm::DbgDeclareInst>(instValue))
|
||||||
|
{
|
||||||
|
printf("BfIRCmd_ClearDebugLocationInst on DbgDeclareInst in %s\n", mModuleName.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((llvm::Instruction*)instValue)->setDebugLoc(llvm::DebugLoc());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BfIRCmd_ClearDebugLocationInstLast:
|
case BfIRCmd_ClearDebugLocationInstLast:
|
||||||
|
@ -4720,7 +4728,14 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
if (!bb->empty())
|
if (!bb->empty())
|
||||||
{
|
{
|
||||||
auto& inst = bb->back();
|
auto& inst = bb->back();
|
||||||
inst.setDebugLoc(llvm::DebugLoc());
|
if (llvm::dyn_cast<llvm::DbgDeclareInst>(&inst))
|
||||||
|
{
|
||||||
|
printf("BfIRCmd_ClearDebugLocationInstLast on DbgDeclareInst\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inst.setDebugLoc(llvm::DebugLoc());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4729,7 +4744,14 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
{
|
{
|
||||||
CMD_PARAM_NOTRANS(llvm::Value*, instValue);
|
CMD_PARAM_NOTRANS(llvm::Value*, instValue);
|
||||||
BF_ASSERT(llvm::isa<llvm::Instruction>(instValue));
|
BF_ASSERT(llvm::isa<llvm::Instruction>(instValue));
|
||||||
((llvm::Instruction*)instValue)->setDebugLoc(mIRBuilder->getCurrentDebugLocation());
|
if ((llvm::dyn_cast<llvm::DbgDeclareInst>(instValue)) && (!mIRBuilder->getCurrentDebugLocation()))
|
||||||
|
{
|
||||||
|
printf("BfIRCmd_UpdateDebugLocation NULL on DbgDeclareInst\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((llvm::Instruction*)instValue)->setDebugLoc(mIRBuilder->getCurrentDebugLocation());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BfIRCmd_SetCurrentDebugLocation:
|
case BfIRCmd_SetCurrentDebugLocation:
|
||||||
|
@ -5394,15 +5416,20 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
llvm::Instruction* insertBeforeInst = NULL;
|
llvm::Instruction* insertBeforeInst = NULL;
|
||||||
if (insertBefore != NULL)
|
if (insertBefore != NULL)
|
||||||
insertBeforeInst = llvm::dyn_cast<llvm::Instruction>(insertBefore);
|
insertBeforeInst = llvm::dyn_cast<llvm::Instruction>(insertBefore);
|
||||||
if (insertBeforeInst != NULL)
|
|
||||||
|
// Protect against lack of debug location
|
||||||
|
if (mIRBuilder->getCurrentDebugLocation())
|
||||||
{
|
{
|
||||||
SetResult(curId, mDIBuilder->insertDeclare(val, (llvm::DILocalVariable*)varInfo, mDIBuilder->createExpression(),
|
if (insertBeforeInst != NULL)
|
||||||
mIRBuilder->getCurrentDebugLocation(), insertBeforeInst));
|
{
|
||||||
}
|
SetResult(curId, mDIBuilder->insertDeclare(val, (llvm::DILocalVariable*)varInfo, mDIBuilder->createExpression(),
|
||||||
else
|
mIRBuilder->getCurrentDebugLocation(), insertBeforeInst));
|
||||||
{
|
}
|
||||||
SetResult(curId, mDIBuilder->insertDeclare(val, (llvm::DILocalVariable*)varInfo, mDIBuilder->createExpression(),
|
else
|
||||||
mIRBuilder->getCurrentDebugLocation(), mIRBuilder->GetInsertBlock()));
|
{
|
||||||
|
SetResult(curId, mDIBuilder->insertDeclare(val, (llvm::DILocalVariable*)varInfo, mDIBuilder->createExpression(),
|
||||||
|
mIRBuilder->getCurrentDebugLocation(), mIRBuilder->GetInsertBlock()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1258,8 +1258,8 @@ void BfModule::SetupIRBuilder(bool dbgVerifyCodeGen)
|
||||||
// code as we walk the AST
|
// code as we walk the AST
|
||||||
//mBfIRBuilder->mDbgVerifyCodeGen = true;
|
//mBfIRBuilder->mDbgVerifyCodeGen = true;
|
||||||
if (
|
if (
|
||||||
(mModuleName == "BeefTest_LLVMType")
|
(mModuleName == "vdata")
|
||||||
|| (mModuleName == "System_ValueType")
|
|| (mModuleName == "")
|
||||||
//|| (mModuleName == "Tests_FuncRefs")
|
//|| (mModuleName == "Tests_FuncRefs")
|
||||||
)
|
)
|
||||||
mBfIRBuilder->mDbgVerifyCodeGen = true;
|
mBfIRBuilder->mDbgVerifyCodeGen = true;
|
||||||
|
|
|
@ -43,13 +43,13 @@ else
|
||||||
echo "Ninja isn't installed, consider installing it for faster build speeds."
|
echo "Ninja isn't installed, consider installing it for faster build speeds."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LLVM_CONFIG=$(command -v llvm-config-13 2>/dev/null || command -v llvm-config 2>/dev/null)
|
LLVM_CONFIG=$(command -v llvm-config-18 2>/dev/null || command -v llvm-config 2>/dev/null)
|
||||||
LLVM_FOUND=0
|
LLVM_FOUND=0
|
||||||
|
|
||||||
if [ -n "$LLVM_CONFIG" ]; then
|
if [ -n "$LLVM_CONFIG" ]; then
|
||||||
LLVM_VERSION=$($LLVM_CONFIG --version)
|
LLVM_VERSION=$($LLVM_CONFIG --version)
|
||||||
LLVM_MAJOR_VERSION=$(echo "$LLVM_VERSION" | cut -d. -f1)
|
LLVM_MAJOR_VERSION=$(echo "$LLVM_VERSION" | cut -d. -f1)
|
||||||
if [ "$LLVM_MAJOR_VERSION" = "13" ]; then
|
if [ "$LLVM_MAJOR_VERSION" = "18" ]; then
|
||||||
LLVM_FOUND=1
|
LLVM_FOUND=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -59,8 +59,8 @@ set -e
|
||||||
|
|
||||||
### Dependencies ###
|
### Dependencies ###
|
||||||
|
|
||||||
if [ ! -f ../extern/llvm_linux_13_0_1/_Done.txt ] && [ $LLVM_FOUND == 0 ]; then
|
if [ ! -f ../extern/llvm_linux_18_1_4/_Done.txt ] && [ $LLVM_FOUND == 0 ]; then
|
||||||
echo "ERROR: LLVM 13 was not detected on your system. Please install the package 'llvm-13-dev' and try again." >&2
|
echo "ERROR: LLVM 18 was not detected on your system. Please install the package 'llvm-18-dev' and try again." >&2
|
||||||
echo "ERROR: As an alternative, you can compile LLVM from source using the script 'extern/llvm_build.sh'." >&2
|
echo "ERROR: As an alternative, you can compile LLVM from source using the script 'extern/llvm_build.sh'." >&2
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
1
extern/llvm_build.bat
vendored
1
extern/llvm_build.bat
vendored
|
@ -9,6 +9,7 @@ git clone --depth 1 --branch llvmorg-18.1.4 --config core.autocrlf=false https:/
|
||||||
@IF EXIST llvm_win64_18_1_4 GOTO HAS_CONFIG
|
@IF EXIST llvm_win64_18_1_4 GOTO HAS_CONFIG
|
||||||
mkdir llvm_win64_18_1_4
|
mkdir llvm_win64_18_1_4
|
||||||
cd llvm_win64_18_1_4
|
cd llvm_win64_18_1_4
|
||||||
|
@REM cmake ../llvm-project_18_1_4/llvm -G"Visual Studio 17 2022" -Ax64 -Thost=x64 -DLLVM_ENABLE_PROJECTS=clang -D CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly"
|
||||||
cmake ../llvm-project_18_1_4/llvm -G"Visual Studio 17 2022" -Ax64 -Thost=x64 -D CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly"
|
cmake ../llvm-project_18_1_4/llvm -G"Visual Studio 17 2022" -Ax64 -Thost=x64 -D CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly"
|
||||||
@IF %ERRORLEVEL% NEQ 0 GOTO HADERROR
|
@IF %ERRORLEVEL% NEQ 0 GOTO HADERROR
|
||||||
@GOTO DOBUILD
|
@GOTO DOBUILD
|
||||||
|
|
40
extern/llvm_build.sh
vendored
40
extern/llvm_build.sh
vendored
|
@ -14,34 +14,34 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -d llvm-project_13_0_1 ]; then
|
if [ ! -d llvm-project_18_1_4 ]; then
|
||||||
if [ -f llvm-13.0.1.src.tar.xz ]; then # if user downloaded llvm-13.0.1.src.tar.xz then use it instead
|
if [ -f llvm-18.1.4.src.tar.xz ]; then # if user downloaded llvm-18.1.4.src.tar.xz then use it instead
|
||||||
tar -xf llvm-13.0.1.src.tar.xz
|
tar -xf llvm-18.1.4.src.tar.xz
|
||||||
mkdir llvm-project_13_0_1
|
mkdir llvm-project_18_1_4
|
||||||
mv llvm-13.0.1.src llvm-project_13_0_1/llvm
|
mv llvm-18.1.4.src llvm-project_18_1_4/llvm
|
||||||
else # shallow git clone llvm repo if llvm-13.0.1.src.tar.xz does not exists
|
else # shallow git clone llvm repo if llvm-18.1.4.src.tar.xz does not exists
|
||||||
git clone --depth 1 --branch llvmorg-13.0.1 https://github.com/llvm/llvm-project.git llvm-project_13_0_1
|
git clone --depth 1 --branch llvmorg-18.1.4 https://github.com/llvm/llvm-project.git llvm-project_18_1_4
|
||||||
fi
|
fi
|
||||||
fi #end if llvm-project_13_0_1 exists
|
fi #end if llvm-project_18_1_4 exists
|
||||||
|
|
||||||
if [ ! -d llvm_linux_13_0_1 ]; then
|
if [ ! -d llvm_linux_18_1_4 ]; then
|
||||||
mkdir llvm_linux_13_0_1
|
mkdir llvm_linux_18_1_4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d llvm_linux_13_0_1/bin ] || [ $FORCE_BUILD == 1 ]; then
|
if [ ! -d llvm_linux_18_1_4/bin ] || [ $FORCE_BUILD == 1 ]; then
|
||||||
cd llvm_linux_13_0_1
|
cd llvm_linux_18_1_4
|
||||||
cmake $USE_NINJA ../llvm-project_13_0_1/llvm -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly" -DCMAKE_BUILD_TYPE:String="Debug"
|
cmake $USE_NINJA ../llvm-project_18_1_4/llvm -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly" -DCMAKE_BUILD_TYPE:String="Debug"
|
||||||
cmake --build . -t $(cat ../llvm_targets.txt)
|
cmake --build . -t $(cat ../llvm_targets.txt)
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d llvm_linux_rel_13_0_1 ]; then
|
if [ ! -d llvm_linux_rel_18_1_4 ]; then
|
||||||
mkdir llvm_linux_rel_13_0_1
|
mkdir llvm_linux_rel_18_1_4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d llvm_linux_rel_13_0_1/bin ] || [ $FORCE_BUILD == 1 ]; then
|
if [ ! -d llvm_linux_rel_18_1_4/bin ] || [ $FORCE_BUILD == 1 ]; then
|
||||||
cd llvm_linux_rel_13_0_1
|
cd llvm_linux_rel_18_1_4
|
||||||
cmake $USE_NINJA ../llvm-project_13_0_1/llvm -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly" -DCMAKE_BUILD_TYPE:String="Release"
|
cmake $USE_NINJA ../llvm-project_18_1_4/llvm -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly" -DCMAKE_BUILD_TYPE:String="Release"
|
||||||
cmake --build . -t $(cat ../llvm_targets.txt)
|
cmake --build . -t $(cat ../llvm_targets.txt)
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
@ -50,6 +50,6 @@ if [ ! -d ../IDE/dist/llvm/bin ]; then
|
||||||
mkdir ../IDE/dist/llvm
|
mkdir ../IDE/dist/llvm
|
||||||
mkdir ../IDE/dist/llvm/bin
|
mkdir ../IDE/dist/llvm/bin
|
||||||
fi
|
fi
|
||||||
cp llvm_linux_rel_13_0_1/bin/llvm-ar ../IDE/dist/llvm/bin
|
cp llvm_linux_rel_18_1_4/bin/llvm-ar ../IDE/dist/llvm/bin
|
||||||
|
|
||||||
echo done > llvm_linux_13_0_1/_Done.txt
|
echo done > llvm_linux_18_1_4/_Done.txt
|
Loading…
Add table
Add a link
Reference in a new issue