Skip to content

Commit 0f727f2

Browse files
committed
Docs: Added architecture addition guide to README.md
I also made very minor changes in the build.sh to make it easier to add new architectures.
1 parent 8adc0f8 commit 0f727f2

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ The resulting binary will be placed in the `build/artifacts/` directory.
135135

136136
</details>
137137

138+
<details open>
139+
<summary>
140+
Adding a custom architecture
141+
</summary> <br />
142+
143+
Adding a new architecture to the build system is straightforward. Follow these steps:
144+
145+
- **Add a cross compiler**: <br />
146+
Add a musl-based compiler to the `ARCHS` dictionary in `src/docker_utils/download_musl_toolchains.py`. You can find musl-based compilers [here](https://more.musl.cc/). <br />
147+
If a musl-based compiler is not available for your architecture, you can instead install a compiler via `apt` in the Dockerfile. However, using a musl-based toolchain is highly recommended.
148+
- **Update the Makefile**: <br />
149+
Add the new architecture to the `ARCHS` variable in the Makefile.
150+
- **Modify `build.sh`**: <br />
151+
Locate the `set_compilation_variables` function in `build.sh`.
152+
- Add the new architecture to the `supported_archs` variable (in the same way as in the Makefile).
153+
- Add a new `if` branch to check for the new architecture, and within it, export the appropriate `HOST` variable using the compiler's target triple.
154+
155+
</details>
156+
138157
<a name="contributing_anchor"></a>
139158
## Contributing
140159

src/compilation/build.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source "$script_dir/full_build_conf.sh"
88
# Don't want random unknown things to fail in the build procecss!
99
set -e
1010

11-
function set_compliation_variables() {
11+
function set_compilation_variables() {
1212
# Set compilation variables such as which compiler to use.
1313
#
1414
# Parameters:
@@ -29,25 +29,21 @@ function set_compliation_variables() {
2929
>&2 fancy_title "Setting compilation variables for $target_arch"
3030

3131
if [[ "$target_arch" == "arm" ]]; then
32-
CROSS=arm-linux-musleabi-
3332
export HOST=arm-linux-musleabi
3433
elif [[ "$target_arch" == "aarch64" ]]; then
35-
CROSS=aarch64-linux-musl-
3634
export HOST=aarch64-linux-musl
3735
elif [[ "$target_arch" == "powerpc" ]]; then
38-
CROSS=powerpc-linux-musl-
3936
export HOST=powerpc-linux-musl
4037
elif [[ "$target_arch" == "mips" ]]; then
41-
CROSS=mips-linux-musl-
4238
export HOST=mips-linux-musl
4339
elif [[ "$target_arch" == "mipsel" ]]; then
44-
CROSS=mipsel-linux-musl-
4540
export HOST=mipsel-linux-musl
4641
elif [[ "$target_arch" == "x86_64" ]]; then
47-
CROSS=x86_64-linux-musl-
4842
export HOST=x86_64-linux-musl
4943
fi
5044

45+
CROSS="${HOST}-"
46+
5147
export CC="${CROSS}gcc"
5248
export CXX="${CROSS}g++"
5349

@@ -790,7 +786,7 @@ function build_gdb_with_dependencies() {
790786
local packages_dir="$build_dir/packages"
791787
local artifacts_dir="$build_dir/artifacts"
792788

793-
set_compliation_variables "$target_arch"
789+
set_compilation_variables "$target_arch"
794790
if [[ $? -ne 0 ]]; then
795791
return 1
796792
fi

0 commit comments

Comments
 (0)