Skip to content

Commit

Permalink
Removes LLVM (obhq#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon authored Mar 16, 2024
1 parent 469686e commit ca98770
Show file tree
Hide file tree
Showing 20 changed files with 115 additions and 658 deletions.
2 changes: 0 additions & 2 deletions .cargo/config.toml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
run: |
flatpak install --noninteractive flathub \
org.kde.Platform//6.6 org.kde.Sdk//6.6 \
org.freedesktop.Sdk.Extension.rust-stable//23.08 \
org.freedesktop.Sdk.Extension.llvm17//23.08
org.freedesktop.Sdk.Extension.rust-stable//23.08
if: ${{ steps.flatpak-runtime.outputs.cache-hit != 'true' }}
- name: Restore build files
uses: actions/cache/restore@v4
Expand Down
49 changes: 1 addition & 48 deletions .github/workflows/ci-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,16 @@ on:
env:
CMAKE_BUILD_PARALLEL_LEVEL: '3'
jobs:
llvm:
name: LLVM for Mac
runs-on: macos-12
outputs:
dist-key: ${{ steps.cache-keys.outputs.dist }}
env:
LLVM_URL: https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz
steps:
- name: Generate cache keys
run: |
hash=$(md5 -qs "$LLVM_URL")
echo "dist=${{ runner.os }}-llvm-$hash" >> $GITHUB_OUTPUT
id: cache-keys
- name: Check cached artifacts
uses: actions/cache/restore@v4
with:
path: lib/llvm
key: ${{ steps.cache-keys.outputs.dist }}
lookup-only: true
id: cache
- name: Download LLVM
run: |
curl -Lo llvm.tar.xz "$LLVM_URL"
tar -xJ --strip-components=1 -f llvm.tar.xz
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Run CMake
run: cmake --install-prefix ${{ github.workspace }}/lib/llvm -Wno-dev -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_ENABLE_ZSTD:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF -DLLVM_TARGETS_TO_BUILD:STRING=X86 -B build llvm
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Build
run: cmake --build build --config Release
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Export artifacts
run: cmake --install build --config Release
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Cache artifacts
uses: actions/cache/save@v4
with:
path: lib/llvm
key: ${{ steps.cache-keys.outputs.dist }}
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
build:
name: Mac
runs-on: macos-12
needs: llvm
env:
CMAKE_PREFIX_PATH: qt/6.6.0/macos
QT_URL_BASE: https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/qt6_660/qt.qt6.660.clang_64/6.6.0-0-202310040910qtbase-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z
QT_URL_SVG: https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/qt6_660/qt.qt6.660.clang_64/6.6.0-0-202310040910qtsvg-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Download LLVM
uses: actions/cache/restore@v4
with:
path: lib/llvm
key: ${{ needs.llvm.outputs.dist-key }}
fail-on-cache-miss: true
- name: Generate cache keys
run: |
require Digest::MD5;
Expand Down Expand Up @@ -104,7 +57,7 @@ jobs:
- name: Update Rust
run: rustup update stable
- name: Run CMake
run: cmake -DOB_BUILD_LLVM:BOOL=OFF --preset mac-release .
run: cmake --preset mac-release .
- name: Build
run: cmake --build --preset mac-release
- name: Run tests
Expand Down
55 changes: 2 additions & 53 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,14 @@ name: CI (Windows)
on:
workflow_call:
env:
CMAKE_BUILD_PARALLEL_LEVEL: '2'
CMAKE_BUILD_PARALLEL_LEVEL: '4'
jobs:
llvm:
name: LLVM for Windows
runs-on: windows-2022
outputs:
dist-key: ${{ steps.cache-keys.outputs.dist }}
steps:
- name: Hash LLVM URL
run: |
$url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz"
$urlhash = [System.BitConverter]::ToString([System.Security.Cryptography.SHA256]::Create().ComputeHash([System.Text.Encoding]::UTF8.GetBytes($url))).Replace("-", "").ToLower()
echo "llvmurl=$url" >> $env:GITHUB_OUTPUT
echo "hash=$urlhash" >> $env:GITHUB_OUTPUT
id: download
- name: Generate cache keys
run: echo "dist=${{ runner.os }}-llvm-${{ steps.download.outputs.hash }}" >> $env:GITHUB_OUTPUT
id: cache-keys
- name: Check cached artifacts
uses: actions/cache/restore@v4
with:
path: lib/llvm
key: ${{ steps.cache-keys.outputs.dist }}
lookup-only: true
id: cache
- name: Download LLVM
run: |
Invoke-WebRequest -Uri ${{ steps.download.outputs.llvmurl }} -OutFile llvm.tar.xz
unxz llvm.tar.xz
tar -x --strip-components=1 -f llvm.tar
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Run CMake
run: cmake --install-prefix ${{ github.workspace }}/lib/llvm -Wno-dev -DLLVM_ENABLE_ZSTD:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF -DLLVM_TARGETS_TO_BUILD:STRING=X86 -B build llvm
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Build
run: cmake --build build --config Release
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Export artifacts
run: cmake --install build --config Release
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
- name: Cache artifacts
uses: actions/cache/save@v4
with:
path: lib/llvm
key: ${{ steps.cache-keys.outputs.dist }}
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
build:
name: Windows
runs-on: windows-2022
needs: llvm
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Download LLVM
uses: actions/cache/restore@v4
with:
path: lib/llvm
key: ${{ needs.llvm.outputs.dist-key }}
fail-on-cache-miss: true
- name: Generate cache keys
run: |
echo "cargo=${{ runner.os }}-cargo" >> $env:GITHUB_OUTPUT
Expand Down Expand Up @@ -100,7 +49,7 @@ jobs:
- name: Update Rust
run: rustup update stable
- name: Run CMake
run: cmake -DOB_BUILD_LLVM:BOOL=OFF --preset windows-release .
run: cmake --preset windows-release .
- name: Build
run: cmake --build --preset windows-release
- name: Run tests
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
/.flatpak-builder/
/.kernel-debug
/build/
/lib/
/src/target/
Cargo.lock
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.21)

project(obliteration)

# Project options.
option(OB_BUILD_LLVM "Download and build the LLVM from source." ON)

# Set warning level to highest. This will propagate to sub-directories too.
if(WIN32)
add_compile_options(/W4)
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ We have a Discord server for discussion about Obliteration and its development.
- [x] Built-in PKG file supports for Fake PKG.
- [x] Game library.
- [x] Emulate system calls instead of user-space libraries.
- [ ] Supports AArch64 CPU.

## System requirements

- Windows 10, Linux or macOS 11+.
- x86-64 CPU.
- x86-64 CPU. We want to support non-x86 but currently we don't have any developers who are willing to work on this.
- A jailbroken PS4 with FTP server that supports SELF decryption.

### Windows-specific requirements
Expand All @@ -53,8 +52,6 @@ Obliteration supports only 4KB/8KB/16KB pages. Most people should not have any p
- Rust on the latest stable channel
- CMake 3.21+
- Make sure you have `Add CMake to the system PATH` selected when installing
- Python 3.6+
- Make sure you have `Add python.exe to PATH` selected when installing

### Linux prerequisites

Expand Down
9 changes: 2 additions & 7 deletions flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ platform-extensions:
- org.freedesktop.Platform.GL.default
sdk: org.kde.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.llvm17
- org.freedesktop.Sdk.Extension.rust-stable
command: obliteration
build-options:
append-path: /usr/lib/sdk/rust-stable/bin
env:
LLVM_SYS_170_PREFIX: /usr/lib/sdk/llvm17
build-args:
- --share=network
- --device=kvm # required for running tests
Expand All @@ -27,14 +24,12 @@ finish-args:
- --socket=pulseaudio
modules:
- name: obliteration
buildsystem: simple # cmake does not work somehow
buildsystem: simple
build-commands:
- cmake -DOB_BUILD_LLVM:BOOL=OFF --preset linux-release .
- cmake --preset linux-release .
- cmake --build --preset linux-release
- cargo test --manifest-path src/Cargo.toml --workspace --exclude core
- cmake --install build --prefix "$FLATPAK_DEST"
- mkdir -pv "$FLATPAK_DEST/lib"
- cp -v /usr/lib/sdk/llvm17/lib/libLLVM-17.so "$FLATPAK_DEST/lib"
sources:
- type: dir
path: .
37 changes: 0 additions & 37 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,6 @@ include(ExternalProject)
find_package(Qt6 COMPONENTS Widgets REQUIRED)
find_package(Threads REQUIRED)

# Setup LLVM target.
set(LLVM_OPTS -DCMAKE_INSTALL_PREFIX:STRING=<INSTALL_DIR> -DLLVM_ENABLE_ZSTD:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF)

if(WIN32)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
list(APPEND LLVM_OPTS -DLLVM_TARGETS_TO_BUILD:STRING=X86)
else()
message(FATAL_ERROR "Target CPU is not supported")
endif()
else()
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
list(APPEND LLVM_OPTS -DLLVM_TARGETS_TO_BUILD:STRING=X86)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
list(APPEND LLVM_OPTS -DLLVM_TARGETS_TO_BUILD:STRING=AArch64)
else()
message(FATAL_ERROR "Target CPU is not supported")
endif()

list(APPEND LLVM_OPTS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE})
endif()

if(OB_BUILD_LLVM)
ExternalProject_Add(llvm
URL https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz
URL_HASH SHA256=95d7eff82945cf05c16a1851d7b391fc2da726b87c1138125e3b6e4d300ab834
DOWNLOAD_NO_PROGRESS true
CMAKE_ARGS -Wno-dev
CMAKE_CACHE_ARGS ${LLVM_OPTS}
SOURCE_SUBDIR llvm
BUILD_ALWAYS ON
INSTALL_DIR ${CMAKE_SOURCE_DIR}/lib/llvm)
endif()

# Setup Rust target.
set(RUST_OUTPUTS $<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/target/debug,${CMAKE_CURRENT_SOURCE_DIR}/target/release>)
set(KERNEL ${RUST_OUTPUTS}/obkrnl${CMAKE_EXECUTABLE_SUFFIX})
Expand All @@ -52,10 +19,6 @@ add_custom_target(core
COMMAND cargo build $<IF:$<CONFIG:Debug>,--profile=dev,--release>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

if(OB_BUILD_LLVM)
add_dependencies(core llvm)
endif()

# Setup application target.
add_executable(obliteration WIN32 MACOSX_BUNDLE
ansi_escape.cpp
Expand Down
1 change: 0 additions & 1 deletion src/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ hv = { path = "../hv" }
iced-x86 = { version = "1.18", features = ["code_asm"] }
libc = "0.2"
llt = { path = "../llt" }
llvm-sys = { version = "170.0.0", features = ["strict-versioning", "prefer-static"] }
macros = { path = "../macros" }
param = { path = "../param" }
serde = { version = "1.0", features = ["derive"] }
Expand Down
21 changes: 0 additions & 21 deletions src/kernel/src/ee/llvm/codegen.rs

This file was deleted.

Loading

0 comments on commit ca98770

Please sign in to comment.