Skip to content

Commit 5222520

Browse files
bootstrap::mlibc: link against libgcc
mlibc required libgcc to build so simply force link mlibc against prebuilt libgcc-binaries; the alternative is to build GCC twice (which is a tedious task). Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
1 parent 6ca54d8 commit 5222520

File tree

2 files changed

+62
-5
lines changed

2 files changed

+62
-5
lines changed

bootstrap.yml

+13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ sources:
4747
'@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub',
4848
'@THIS_SOURCE_DIR@/mpfr-3.1.6/config.sub']
4949

50+
# This repository contains several precompiled freestanding libgcc.a libraries,
51+
# for different architectural targets.
52+
- name: libgcc-binaries
53+
subdir: 'bundled'
54+
git: 'https://github.com/mintsuki/libgcc-binaries.git'
55+
branch: 'trunk'
56+
5057
- name: mlibc
5158
subdir: 'bundled'
5259
git: 'https://github.com/managarm/mlibc'
@@ -815,6 +822,7 @@ packages:
815822
tools_required:
816823
- tool: host-gcc
817824
stage_dependencies: [compiler]
825+
sources_required: ['libgcc-binaries']
818826
implict_package: true
819827
pkgs_required:
820828
- mlibc-headers
@@ -832,6 +840,11 @@ packages:
832840
- '-Dbuildtype=debug'
833841
- '-Dlinux_kernel_headers=@BUILD_ROOT@/packages/linux-headers/usr/include'
834842
- '@THIS_SOURCE_DIR@'
843+
environ:
844+
# mlibc requires libgcc to build so simply force link mlibc against
845+
# prebuilt libgcc-binaries; the alternative is to build GCC twice (which
846+
# is a tedious task).
847+
LDFLAGS: '-Wl,@THIS_SOURCE_DIR@/../libgcc-binaries/libgcc-x86_64.a'
835848
build:
836849
- args: ['ninja']
837850
- args: ['ninja', 'install']

patches/mlibc/mlibc.patch

+49-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
From 7ffa4a93ab4c1a5a5dd129dce1d03f784ace2e06 Mon Sep 17 00:00:00 2001
1+
From 8b458716d4a65d2da069678130c32c30395fed89 Mon Sep 17 00:00:00 2001
22
From: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
3-
Date: Mon, 13 Mar 2023 16:14:34 +1100
3+
Date: Tue, 28 Mar 2023 17:15:29 +1100
44
Subject: [PATCH] <xxx>
55

66
---
77
.gitignore | 2 ++
8-
options/ansi/generic/stdlib-stubs.cpp | 6 ++++--
8+
meson.build | 32 ++++++++++++++++-----------
9+
options/ansi/generic/stdlib-stubs.cpp | 6 +++--
910
options/glibc/generic/execinfo.cpp | 5 +++--
1011
options/rtdl/generic/linker.cpp | 2 +-
11-
sysdeps/aero/generic/sockets.cpp | 25 +++++++++++++++++++++++++
12-
5 files changed, 35 insertions(+), 5 deletions(-)
12+
sysdeps/aero/generic/sockets.cpp | 25 +++++++++++++++++++++
13+
6 files changed, 54 insertions(+), 18 deletions(-)
1314

1415
diff --git a/.gitignore b/.gitignore
1516
index fdd60a0..9f811f4 100644
@@ -21,6 +22,49 @@ index fdd60a0..9f811f4 100644
2122
.vscode
2223
+# clangd cache files:
2324
+.cache
25+
diff --git a/meson.build b/meson.build
26+
index 2261926..92b936d 100644
27+
--- a/meson.build
28+
+++ b/meson.build
29+
@@ -315,19 +315,25 @@ subdir('options/bsd')
30+
rtlib_deps = []
31+
32+
if not headers_only
33+
- libgcc = meson.get_compiler('c').find_library('gcc', required: false)
34+
-
35+
- compiler_rt_name = 'libclang_rt.builtins-' + host_machine.cpu_family()
36+
- compiler_rt = meson.get_compiler('c').find_library(compiler_rt_name, required: false)
37+
-
38+
- if libgcc.found()
39+
- rtlib_deps += libgcc
40+
- elif compiler_rt.found()
41+
- rtlib_deps += compiler_rt
42+
- else
43+
- error('neither libgcc nor ' + compiler_rt_name + ' was found')
44+
- endif
45+
-
46+
+ # XXX: for Aero and Lyre, we force link mlibc against prebuilt
47+
+ # libgcc-binaries; the alternative is to build GCC twice (which
48+
+ # is a tedious task).
49+
+ #
50+
+ # TODO: maybe upstream this by having a libgcc path option.
51+
+
52+
+ # libgcc = meson.get_compiler('c').find_library('gcc', required: false)
53+
+ #
54+
+ # compiler_rt_name = 'libclang_rt.builtins-' + host_machine.cpu_family()
55+
+ # compiler_rt = meson.get_compiler('c').find_library(compiler_rt_name, required: false)
56+
+ #
57+
+ # if libgcc.found()
58+
+ # rtlib_deps += libgcc
59+
+ # elif compiler_rt.found()
60+
+ # rtlib_deps += compiler_rt
61+
+ # else
62+
+ # error('neither libgcc nor ' + compiler_rt_name + ' was found')
63+
+ # endif
64+
+
65+
ld_cpp_args = [
66+
'-fvisibility=hidden',
67+
'-fno-stack-protector',
2468
diff --git a/options/ansi/generic/stdlib-stubs.cpp b/options/ansi/generic/stdlib-stubs.cpp
2569
index c0e54fe..ddeec8a 100644
2670
--- a/options/ansi/generic/stdlib-stubs.cpp

0 commit comments

Comments
 (0)