Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from includeos:master #12

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open

Conversation

pull[bot]
Copy link

@pull pull bot commented Apr 29, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

sourabhligade and others added 25 commits August 1, 2023 20:05
Corrected Grammatical error
Added a period at the end of the sentence for better readability and Punctuation
Signed-off-by: RoboSchmied <[email protected]>
Usage: nix-build

This is something I wrote in february 2021 as a proof of concept. It
hasn't been tested beyond the fact that it builds, and produces some
header files and libraries in the install tree. Everything is pinned, so
it builds the same now as it did back then.
It doesn't make sense to pin the sources anymore, now that the Nix
expression is in-tree.
Because they are build time tools. (This change only matters for
cross-compilation.)
@pull pull bot added the ⤵️ pull label Apr 29, 2024
alfreb and others added 30 commits May 2, 2024 06:57
Build musl for IncludeOS with nix and clang
- Moves dependencies into deps/x/default.nix
- Builds some packages statically
- Builds musl-includeos, which can be an input to other packages
- Some open questions:
   - Should we use pkgStatic as base? Currently fails on cmake
   - Should we use makeStatic instead of makeStaticLibraries, does it matter?

IncludeOS build fails, but nix-shell works
- Set CROSS_COMPILE to allow configure script to find ar/bintools
- Enable parallel builds
- Remove unused build inputs
- Add default.nix to deps/http-parser
- Use recent version of packages to get static build support
Patch Makefile to use AR and RANLIB variables.
- Use llvmPackages_7.stdenv instead of libcxxStdenv to let llvmPackages pick
  the right configuration. This fixes the cmath signbit errors.
- Add asserts to fail early if not in a linux/musl stdenv
- Override cmake package to fix static build

nix-build now only fails on s2n-tls, which doesn't have a static build yet
First steps towards nix static build
- Include <limits.h> for IOV_MAX - this is correct according to posix.
  See https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/uio.h.html.
- Disable `https/s2n_server.cpp` until we figure out how to build s2n.
- Remove exception specifier from at_quick_exit to conform with musl.
  Musl defined this in `include/stdlib.h` without `noexcept`.
This reverts commit 07ad9e2.

Adds back vmbuild, for easier maintanence. It was moved to a separate repo,
includeos/vmbuild, but we now want to have all dependencies in one place.
Revert "tools: Remove vmbuild"
Or else nixpkgs might look for them impurely (in $HOME), and that's a
source of non-reproducibility.
Instead of manually inheriting stdenv all over, introduce a nixpkgs
overlay and a new package set/scope called pkgsIncludeOS, where stdenv
is set once and automatically used by callPackage.

I created the overlay in a separate file (overlay.nix) in case we want
to re-use it for other `import nixpkgs { ... }` calls.

Since the Nix files currently become part of the input to the IncludeOS
build, this creates a new derivation (build), but the output content is
the same as before (checked with diffoscope).
Simplify by constructing pkgsIncludeOS straight from the first pkgs set
(glibc based), instead of pulling it from pkgs.pkgsStatic.

Rebuilds, but output content is the same.
I don't see why they need to be statically linked.

Rebuilds, but with same output content.
Add hello world that compiles and links against IncludeOS libs.

- cmake/os.cmake:
  - Delete unused function `expects` (it's a bit convoluted)
  - Temporarily disable ELF_SYMBOLS until we reintegrate `vmbuild`
  - Temporarily disable symbol stripping; it writes to invalid paths.
- default.nix:
  - Add global llvmPkgs to control LLVM version in one place.
  - Add derivation for the example
  - Exposes link time dependencies as cmake variables:
    - libcxx, LLVM's libc++
    - libcxxabi, LLVM's C++ abi
    - libunwind, LLVM's stack unwinder.
  - Validate the paths of the individual libraries in preBuild
  - Add an encouraging note in `postBuild`. Can be deleted.
- example/CMakeLists.txt:
  - Explicitly control link ordering in LIBRARIES, picked up by os.cmake.
    - Should move to os.cmake or something - it will be the same for most apps.
    - Some duplicate entries are necessary to resolve mutual dependencies.
- example/src/main.cpp: hello world.
  - Has #include <os> / <service> to make sure I compile against IncludeOS.
  - We should be able to use a plain main as well.
It links! An example binary linking with IncludeOS (WIP)
vmbuild doesn't require the includeos build environment, but needs the source code.
To avoid a circular dependency, this creates a vmbuild.nix in the root directory
and includes the parts of the source code that vmbuild needs.

`nix-build ./vmbuild.nix` produces vmbuild and elf_syms binaries in result/bin.

This commit also removes conan specific details from vmbuild/CMakeLists.txt
Moves the example to a separate nix-file.

To link the example binary, run:

nix-build ./example.nix
Separate nix-file for example and vmbuild, fix conflicts
nix: create a new scope for IncludeOS packages
Adds a nix shell for building an IncludeOS bootable, where IncludeOS is
provided as a local cmake installation, for rapid iteration.

1. Build IncludeOS locally, using the default.nix as a shell:
   1. $ nix-shell default.nix
   2. $ mkdir build_includeos && pushd build_includeos
   3. $ cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/home/<you>/includeos_install
   4. $ make -j install
   5. $ popd
2. $ export INCLUDEOS_PACKAGE=/home/<you>/includeos_install
3. $ nix-shell --run 'make -j12 && $vmbuild hello_includeos.elf.bin $bootloader' && file build_example/hello_includeos.elf.bin.img

This should produce a bootable image. You can skip the --run and iterate on the
bootable in the nix shell.

This means there are two nix shells; one for developing the OS and one for the
bootable. This is dumb, but IncludeOS requires some older packages, like old GSL,
which is not a restriction the bootable should need to have. Stil, we should
probably harmonize the two.
This avoids rebuilding the OS from in-tree packages that depend on ./default.nix
They are only needed during eval. Changes in the derivation should trigger rebuild.
Working nix-shell - a bit convoluted but allows quick iteration.
Only include required files in IncludeOS nix package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants