Skip to content

Commit 90094ea

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 90094ea

File tree

2 files changed

+73
-6
lines changed

2 files changed

+73
-6
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

+60-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
From 7ffa4a93ab4c1a5a5dd129dce1d03f784ace2e06 Mon Sep 17 00:00:00 2001
1+
From 40764fb1dfc0a1a0dc77f0a6b91937fc95032fd6 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: Mon, 27 Mar 2023 20:43:27 +1100
44
Subject: [PATCH] <xxx>
55

66
---
77
.gitignore | 2 ++
8-
options/ansi/generic/stdlib-stubs.cpp | 6 ++++--
9-
options/glibc/generic/execinfo.cpp | 5 +++--
8+
meson.build | 42 +++++++++++++++------------
9+
options/ansi/generic/stdlib-stubs.cpp | 6 ++--
10+
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, 59 insertions(+), 23 deletions(-)
1314

1415
diff --git a/.gitignore b/.gitignore
1516
index fdd60a0..9f811f4 100644
@@ -21,6 +22,59 @@ index fdd60a0..9f811f4 100644
2122
.vscode
2223
+# clangd cache files:
2324
+.cache
25+
diff --git a/meson.build b/meson.build
26+
index 2261926..3ddf806 100644
27+
--- a/meson.build
28+
+++ b/meson.build
29+
@@ -315,24 +315,30 @@ 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+
- ld_cpp_args = [
47+
- '-fvisibility=hidden',
48+
- '-fno-stack-protector',
49+
- '-DMLIBC_BUILDING_RTDL'
50+
- ]
51+
+ # XXX: for Aero and Lyre, we force link mlibc against prebuilt
52+
+ # libgcc-binaries; the alternative is to build GCC twice (which
53+
+ # is a tedious task).
54+
+ #
55+
+ # TODO: maybe upstream this by having a libgcc path option.
56+
+
57+
+ # libgcc = meson.get_compiler('c').find_library('gcc', required: false)
58+
+ #
59+
+ # compiler_rt_name = 'libclang_rt.builtins-' + host_machine.cpu_family()
60+
+ # compiler_rt = meson.get_compiler('c').find_library(compiler_rt_name, required: false)
61+
+ #
62+
+ # if libgcc.found()
63+
+ # rtlib_deps += libgcc
64+
+ # elif compiler_rt.found()
65+
+ # rtlib_deps += compiler_rt
66+
+ # else
67+
+ # error('neither libgcc nor ' + compiler_rt_name + ' was found')
68+
+ # endif
69+
+ #
70+
+ # ld_cpp_args = [
71+
+ # '-fvisibility=hidden',
72+
+ # '-fno-stack-protector',
73+
+ # '-DMLIBC_BUILDING_RTDL'
74+
+ # ]
75+
76+
libc_all_sources = [
77+
libc_sources,
2478
diff --git a/options/ansi/generic/stdlib-stubs.cpp b/options/ansi/generic/stdlib-stubs.cpp
2579
index c0e54fe..ddeec8a 100644
2680
--- a/options/ansi/generic/stdlib-stubs.cpp

0 commit comments

Comments
 (0)