Skip to content

Commit

Permalink
Merge pull request #260 from no92/mlibc-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke authored Oct 7, 2023
2 parents 3f9bbbe + 8e98989 commit 9e8693c
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 0 deletions.
91 changes: 91 additions & 0 deletions bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,23 @@ tools:
- args: ['ninja', 'install']
quiet: true

- name: host-xxd
labels: [aarch64]
architecture: '@OPTION:arch@'
source:
subdir: 'ports'
git: 'https://github.com/vim/vim.git'
tag: 'v9.0.0633'
version: '9.0.0633'
configure:
- args: ['cp', '@THIS_SOURCE_DIR@/src/xxd/xxd.c', '@THIS_BUILD_DIR@/']
- args: ['cp', '@THIS_SOURCE_DIR@/src/xxd/Makefile', '@THIS_BUILD_DIR@/']
compile:
- args: ['make']
install:
- args: ['mkdir', '-p', '@PREFIX@/bin/']
- args: ['cp', '@THIS_BUILD_DIR@/xxd', '@PREFIX@/bin/']

- name: cross-binutils
labels: [aarch64, riscv64]
architecture: '@OPTION:arch@'
Expand Down Expand Up @@ -686,6 +703,31 @@ tools:
install:
- args: ['ninja', 'install']

- name: host-hdoc
labels: [aarch64]
architecture: '@OPTION:arch@'
source:
subdir: 'ports'
git: 'https://github.com/hdoc/hdoc'
tag: '1.4.1'
version: '1.4.1'
tools_required:
- host-llvm-toolchain
- host-xxd
- virtual: pkgconfig-for-host
program_name: host-pkg-config
configure:
- args:
- 'meson'
- '--native-file'
- '@SOURCE_ROOT@/scripts/meson.native-file'
- '--prefix=@PREFIX@'
- '@THIS_SOURCE_DIR@'
compile:
- args: ['ninja']
install:
- args: ['ninja', 'install']

packages:
- name: binutils
metadata:
Expand Down Expand Up @@ -1354,6 +1396,43 @@ packages:
quiet: true
- args: ['ln', '-sf', 'crt0.o', '@THIS_COLLECT_DIR@/usr/lib/crt1.o']

- name: mlibc-docs
labels: [aarch64]
architecture: '@OPTION:arch@'
from_source: mlibc
tools_required:
- host-llvm-toolchain
- host-managarm-tools
- bootstrap-system-gcc
- host-protoc
- host-hdoc
- host-pkg-config
- virtual: pkgconfig-for-target
triple: "@OPTION:arch-triple@"
pkgs_required:
- linux-headers
- mlibc-headers
- frigg
configure:
- args:
- 'meson'
- 'setup'
- '--cross-file'
- '@SOURCE_ROOT@/scripts/meson-@OPTION:[email protected]'
- '--prefix=/usr'
- '--libdir=lib'
- '--buildtype=debugoptimized'
- '--wrap-mode=nofallback'
- '-Dmlibc_no_headers=true'
- '-Ddisable_crypt_option=true'
- '-Ddisable_iconv_option=true'
- '-Ddisable_intl_option=true'
- '-Dlinux_kernel_headers=@SYSROOT_DIR@/usr/src/linux-headers'
- '@THIS_SOURCE_DIR@'
build:
- args: ['hdoc']
workdir: '@THIS_BUILD_DIR@'

- name: protobuf
labels: [aarch64]
architecture: '@OPTION:arch@'
Expand Down Expand Up @@ -1780,6 +1859,18 @@ tasks:
workdir: '@BUILD_ROOT@'
containerless: true

- name: mlibc-docs
pkgs_required:
- mlibc-docs
args:
- 'python'
- '-m'
- 'http.server'
- '8080'
- '-d'
- '@BUILD_ROOT@/pkg-builds/mlibc-docs/docs'
containerless: true

- name: mlibc-sysdeps
args:
- '@SOURCE_ROOT@/scripts/compile-mlibc-sysdeps.sh'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From d279dfb0035ab90ca97cdca1e7b47ccbc0d2c556 Mon Sep 17 00:00:00 2001
From: no92 <[email protected]>
Date: Sat, 1 Oct 2022 19:04:39 +0200
Subject: [PATCH 1/2] xxd: reliably name the variable independent of build root
path

As xxd uses the path name to name the variable, and the source hardcodes
the assumption that the build dir is exactly one level below the project
root, having that at a different place breaks the build. To circumvent
this issue, the variable name is passed as an extra arg to the
generator.
---
meson.build | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index b782618..ff74dfd 100644
--- a/meson.build
+++ b/meson.build
@@ -38,8 +38,12 @@ asset_files = [
]
gen = generator(find_program('xxd'),
output: '@[email protected]',
- arguments: ['-i', '@INPUT@', '@OUTPUT@'])
-assets_src = gen.process(asset_files)
+ arguments: ['-i', '-name', '@EXTRA_ARGS@', '@INPUT@', '@OUTPUT@'])
+assets_src = []
+
+foreach asset_file : asset_files
+ assets_src += gen.process(asset_file, extra_args: '___' + asset_file.underscorify())
+endforeach

# Subproject configuration #defines
add_project_arguments('-DCPPHTTPLIB_OPENSSL_SUPPORT', language: 'cpp')
--
2.40.1

29 changes: 29 additions & 0 deletions patches/host-hdoc/0002-LLVM-16-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From a2718b523036a8aa99ef70f5518cd59d85aae95a Mon Sep 17 00:00:00 2001
From: no92 <[email protected]>
Date: Thu, 3 Aug 2023 01:12:58 +0200
Subject: [PATCH 2/2] LLVM 16 support

---
src/frontend/Frontend.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/frontend/Frontend.cpp b/src/frontend/Frontend.cpp
index 36f25d3..b90e757 100644
--- a/src/frontend/Frontend.cpp
+++ b/src/frontend/Frontend.cpp
@@ -151,10 +151,10 @@ hdoc::frontend::Frontend::Frontend(int argc, char** argv, hdoc::types::Config* c
// The actual output we care about goes to tempFile, and we use /dev/null as a stand-in for the file the compiler
// reads.
llvm::SmallVector<llvm::StringRef> compilerFlags = {compilerPath.get(), "-E", "-Wp,-v", "-xc++", "/dev/null"};
- llvm::Optional<llvm::StringRef> redirects[] = {llvm::None, {"/dev/null"}, {tempFile}}; // stdin, stdout, stderr
+ std::optional<llvm::StringRef> redirects[] = {std::nullopt, {"/dev/null"}, {tempFile}}; // stdin, stdout, stderr

std::string errMsg = "";
- int rc = llvm::sys::ExecuteAndWait(compilerPath.get(), compilerFlags, llvm::None, redirects, 10, 0, &errMsg);
+ int rc = llvm::sys::ExecuteAndWait(compilerPath.get(), compilerFlags, std::nullopt, redirects, 10, 0, &errMsg);
if (rc != 0) {
spdlog::error("Failed to determine the system include paths ({}, {}).", rc, errMsg);
return;
--
2.40.1

23 changes: 23 additions & 0 deletions scripts/compile-mlibc-arches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
mlibc_path="$1"
kernel_header_path="$2"
shift 2
[ $# -eq 0 ] && set -- x86_64 aarch64 riscv64 x86

mkdir -p ci
cd ci || exit 1

for arch in "$@"; do
mkdir -p "build-$arch"
cat >"build-$arch/bootstrap-site.yml" <<EOF
define_options:
arch: "$arch"
EOF
ln -sf "$mlibc_path" src/mlibc
ln -sf "$kernel_header_path" src/linux
cp "$mlibc_path/ci/bootstrap.yml" "src/"
cd "build-$arch" || exit 1
xbstrap init ../src
xbstrap install --rebuild mlibc
meson test -C pkg-builds/mlibc -v
done
26 changes: 26 additions & 0 deletions scripts/compile-mlibc-arches.sh.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
mlibc_path="$1"
kernel_header_path="$2"
shift 2
[ $# -eq 0 ] && set -- x86_64 aarch64 riscv64
cd pkg-builds/ || exit 1
for arch in "$@"; do
if [ ! -d "linux-headers-$arch" ]; then
mkdir -p "linux-headers-$arch"
cp -Tr "$2" "linux-headers-$arch"
fi
if [ ! -d "mlibc-$arch" ]; then
meson setup \
--prefix=/usr \
--libdir=lib \
-Dbuild_tests=true \
-Ddefault_library=static \
-Db_sanitize=undefined \
"-Dlinux_kernel_headers=$kernel_header_path" \
--cross-file "$mlibc_path"/ci/linux-"$arch".cross-file mlibc-"$arch" "$mlibc_path" --wipe
fi
ninja -C mlibc-"$arch"
# meson test -C mlibc-"$arch"
# mkdir -p "../packages/mlibc-$arch"
# DESTDIR="../packages/mlibc-$arch" ninja -C "mlibc-$arch" install
done

0 comments on commit 9e8693c

Please sign in to comment.