Skip to content

Commit 439cf90

Browse files
authored
Merge pull request #78 from dawidpawliczek4/macos-support
Add macOS support
2 parents e8551f0 + bba5d49 commit 439cf90

File tree

10 files changed

+111
-22
lines changed

10 files changed

+111
-22
lines changed

.github/workflows/build.yml

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
- uses: lukka/get-cmake@latest
2525
with:
26-
cmakeVersion: '~3.24.0'
26+
cmakeVersion: '~3.29.0'
2727

2828
- name: Install dependencies
2929
run: |
@@ -55,7 +55,7 @@ jobs:
5555

5656
- uses: lukka/get-cmake@latest
5757
with:
58-
cmakeVersion: '~3.24.0'
58+
cmakeVersion: '~3.29.0'
5959

6060
- name: Install dependencies
6161
run: |
@@ -88,7 +88,7 @@ jobs:
8888

8989
- uses: lukka/get-cmake@latest
9090
with:
91-
cmakeVersion: '~3.24.0'
91+
cmakeVersion: '~3.29.0'
9292

9393
- name: Install dependencies
9494
run: |
@@ -119,7 +119,7 @@ jobs:
119119

120120
- uses: lukka/get-cmake@latest
121121
with:
122-
cmakeVersion: '~3.24.0'
122+
cmakeVersion: '~3.29.0'
123123

124124
- name: Install dependencies
125125
run: |
@@ -141,3 +141,59 @@ jobs:
141141
with:
142142
name: build-artifacts-clang-lto
143143
path: build/
144+
145+
build-clang-macos:
146+
runs-on: macos-latest
147+
148+
steps:
149+
- uses: actions/checkout@v4
150+
with:
151+
submodules: true
152+
153+
- uses: lukka/get-cmake@latest
154+
with:
155+
cmakeVersion: '~3.29.0'
156+
157+
- name: Install dependencies
158+
run: |
159+
brew install llvm lld cmake qemu dosfstools e2fsprogs mtools include-what-you-use
160+
161+
- name: Generate and build
162+
uses: lukka/run-cmake@v10
163+
with:
164+
configurePreset: 'ci-clang'
165+
buildPreset: 'ci-clang'
166+
167+
- name: Upload artifacts
168+
uses: actions/upload-artifact@v4
169+
with:
170+
name: build-artifacts-clang-macos
171+
path: build/
172+
173+
build-clang-macos-lto:
174+
runs-on: macos-latest
175+
176+
steps:
177+
- uses: actions/checkout@v4
178+
with:
179+
submodules: true
180+
181+
- uses: lukka/get-cmake@latest
182+
with:
183+
cmakeVersion: '~3.29.0'
184+
185+
- name: Install dependencies
186+
run: |
187+
brew install llvm lld cmake qemu dosfstools e2fsprogs mtools include-what-you-use
188+
189+
- name: Generate and build
190+
uses: lukka/run-cmake@v10
191+
with:
192+
configurePreset: 'ci-clang-lto'
193+
buildPreset: 'ci-clang-lto'
194+
195+
- name: Upload artifacts
196+
uses: actions/upload-artifact@v4
197+
with:
198+
name: build-artifacts-clang-macos-lto
199+
path: build/

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,9 @@ CMakeUserPresets.json
7777
docs/xml/
7878
# HTML of the sphinx page
7979
docs/build/
80+
81+
# JetBrains IDEs files
82+
.idea/
83+
84+
# macOS files
85+
.DS_Store
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
cmake_minimum_required(VERSION 3.13)
2-
31
if(RISCV_CLANG_TOOLCHAIN_INCLUDED)
42
return()
53
endif()
64
set(RISCV_CLANG_TOOLCHAIN_INCLUDED TRUE)
75

86
include(${CMAKE_CURRENT_LIST_DIR}/riscv64-common.cmake)
97

10-
set(CMAKE_ASM_COMPILER clang)
11-
set(CMAKE_C_COMPILER clang)
8+
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
9+
execute_process(
10+
COMMAND brew --prefix llvm
11+
OUTPUT_VARIABLE LLVM_PREFIX
12+
OUTPUT_STRIP_TRAILING_WHITESPACE
13+
)
14+
set(CMAKE_PREFIX_PATH "${LLVM_PREFIX}")
15+
set(CMAKE_C_USING_LINKER_LLD "-fuse-ld=lld")
16+
set(CMAKE_ASM_USING_LINKER_LLD "-fuse-ld=lld")
17+
set(CMAKE_LINKER_TYPE LLD)
18+
endif()
19+
20+
find_program(CMAKE_C_COMPILER clang REQUIRED)
21+
find_program(CMAKE_ASM_COMPILER clang REQUIRED)

CMake/toolchains/riscv64-gcc.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
cmake_minimum_required(VERSION 3.13)
2-
31
if(RISCV_GCC_TOOLCHAIN_INCLUDED)
42
return()
53
endif()

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.24)
1+
cmake_minimum_required(VERSION 3.29)
22
project(BigOS LANGUAGES C ASM)
33

44
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": 5,
33
"cmakeMinimumRequired": {
44
"major": 3,
5-
"minor": 24,
5+
"minor": 29,
66
"patch": 0
77
},
88
"include": [

docs/source/pages/developers/env/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ If You are using a different operating system and a guide for it doesn't work or
66

77
.. toctree::
88
arch_linux
9+
macos
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
macOS
2+
=====
3+
4+
Before you begin, ensure you have the `Homebrew <https://brew.sh/>`_ package manager installed on your system.
5+
6+
You will also need the Xcode Command Line Tools, which can be installed by running ``xcode-select --install`` in your terminal.
7+
8+
To install all necessary packages, run:
9+
10+
.. code-block:: bash
11+
12+
brew install llvm lld cmake qemu dosfstools e2fsprogs mtools include-what-you-use
13+
14+
To build the project, use one of the Clang presets, e.g.:
15+
16+
.. code-block:: bash
17+
18+
cmake --preset debug-clang
19+
cmake --build build

src/example_dtree/startup.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ extern u8 __bss_end [[gnu::weak]][];
2424

2525
extern int main(u32 hartid, const void* fdt);
2626

27-
[[gnu::section(".init.enter"), gnu::naked]]
28-
void _enter(void) { // NOLINT
29-
__asm__ volatile(".option push\n\t"
30-
".option norelax\n\t"
31-
"la gp, __global_pointer$\n\t"
32-
".option pop\n\t"
33-
"la sp, _sp\n\t"
34-
"jal zero, _start");
35-
}
36-
3727
[[noreturn, gnu::noinline]]
3828
void _Exit([[maybe_unused]] int return_code) { // NOLINT
3929
while (1) wfi();

src/example_dtree/startup_enter.S

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.section .init.enter, "ax"
2+
.global _enter
3+
_enter:
4+
.option push
5+
.option norelax
6+
la gp, __global_pointer$
7+
.option pop
8+
la sp, _sp
9+
jal zero, _start

0 commit comments

Comments
 (0)