From 83c60803803215aaf22c7c0021e6547709d3b898 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 16 Apr 2024 22:02:31 -0500 Subject: [PATCH 01/13] yml config for building with Cosmopolitan Libc --- .github/workflows/release.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5c557dc..c0c9df1c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,3 +60,38 @@ jobs: ./dist/*.zip ./*.zip ./*.msi + + release-cosmo: + permissions: + contents: write # for softprops/action-gh-release to create GitHub release + name: Build release binaries for Cosmo + runs-on: ubuntu-latest + steps: + - name: Checkout superconfigure repo + run: git clone https://github.com/ahgamut/superconfigure + - name: support ape bins and SSL things + run: | + cd superconfigure + bash ./.github/scripts/setup + - name: build Cosmo + working-directory: /ahgamut/superconfigure + run: bash ./.github/scripts/cosmo + - name: clone Janet latest commit + working-directory: /ahgamut/superconfigure + run: | + make o/lang/janet/downloaded + cd o/lang/janet/janet + git pull origin master + - name: Set the version + run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + - name: Set the platform + run: echo "platform=cosmo" >> $GITHUB_ENV + - name: build Janet APE binary + working-directory: /ahgamut/superconfigure + run: make o/lang/janet/built.fat + - name: push binary to github + uses: softprops/action-gh-release@v1 + with: + draft: true + files: | + results/bin/janet.com From af511f1f550ee3eac9176b27333c00321ae5d103 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 16 Apr 2024 22:15:54 -0500 Subject: [PATCH 02/13] patch folder location --- .github/workflows/release.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c0c9df1c..114de092 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,12 +67,16 @@ jobs: name: Build release binaries for Cosmo runs-on: ubuntu-latest steps: + - name: create build folder + run: | + sudo mkdir -p /ahgamut + sudo chmod -R 0777 /ahgamut - name: Checkout superconfigure repo + working-directory: /ahgamut run: git clone https://github.com/ahgamut/superconfigure - name: support ape bins and SSL things - run: | - cd superconfigure - bash ./.github/scripts/setup + working-directory: /ahgamut/superconfigure + run: bash ./.github/scripts/setup - name: build Cosmo working-directory: /ahgamut/superconfigure run: bash ./.github/scripts/cosmo From 4173645b81f757820783121638f1951b4d592d23 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 16 Apr 2024 22:23:12 -0500 Subject: [PATCH 03/13] missing folder --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 114de092..93e7ef8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,6 +94,7 @@ jobs: working-directory: /ahgamut/superconfigure run: make o/lang/janet/built.fat - name: push binary to github + working-directory: /ahgamut/superconfigure uses: softprops/action-gh-release@v1 with: draft: true From 174b5f6686894d2a65e0940708f084c23a4c5ed2 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 16 Apr 2024 22:24:31 -0500 Subject: [PATCH 04/13] missing folder --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93e7ef8b..56b85e91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,9 +94,8 @@ jobs: working-directory: /ahgamut/superconfigure run: make o/lang/janet/built.fat - name: push binary to github - working-directory: /ahgamut/superconfigure uses: softprops/action-gh-release@v1 with: draft: true files: | - results/bin/janet.com + /ahgamut/superconfigure/results/bin/janet.com From 4ed7db4f91b4fc51c40c36dc876c87d827b0ec76 Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 19 Apr 2024 10:56:46 -0500 Subject: [PATCH 05/13] simplify naming --- .github/workflows/release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 56b85e91..b4b0f061 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,19 +69,19 @@ jobs: steps: - name: create build folder run: | - sudo mkdir -p /ahgamut - sudo chmod -R 0777 /ahgamut + sudo mkdir -p /sc + sudo chmod -R 0777 /sc - name: Checkout superconfigure repo - working-directory: /ahgamut + working-directory: /sc run: git clone https://github.com/ahgamut/superconfigure - name: support ape bins and SSL things - working-directory: /ahgamut/superconfigure + working-directory: /sc/superconfigure run: bash ./.github/scripts/setup - name: build Cosmo - working-directory: /ahgamut/superconfigure + working-directory: /sc/superconfigure run: bash ./.github/scripts/cosmo - name: clone Janet latest commit - working-directory: /ahgamut/superconfigure + working-directory: /sc/superconfigure run: | make o/lang/janet/downloaded cd o/lang/janet/janet @@ -91,11 +91,11 @@ jobs: - name: Set the platform run: echo "platform=cosmo" >> $GITHUB_ENV - name: build Janet APE binary - working-directory: /ahgamut/superconfigure + working-directory: /sc/superconfigure run: make o/lang/janet/built.fat - name: push binary to github uses: softprops/action-gh-release@v1 with: draft: true files: | - /ahgamut/superconfigure/results/bin/janet.com + /sc/superconfigure/results/bin/janet.com From bf680fb5d32183f8233227bdbf28363597539f49 Mon Sep 17 00:00:00 2001 From: Gautham Date: Sat, 20 Apr 2024 22:09:10 -0500 Subject: [PATCH 06/13] simplify janet APE build --- .github/cosmo/build | 11 +++++++++++ .github/cosmo/recipe.mk | 26 ++++++++++++++++++++++++++ .github/cosmo/setup | 28 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 22 +++++----------------- 4 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 .github/cosmo/build create mode 100644 .github/cosmo/recipe.mk create mode 100644 .github/cosmo/setup diff --git a/.github/cosmo/build b/.github/cosmo/build new file mode 100644 index 00000000..22c51c46 --- /dev/null +++ b/.github/cosmo/build @@ -0,0 +1,11 @@ +#!/bin/sh + +# copy janet recipe +mkdir -p /sc/sueprconfigure/janet +cp ./.github/cosmo/recipe.mk /sc/superconfigure/BUILD.mk +cat 'include janet/BUILD.mk' >> /sc/superconfigure/custom.mk + +export SOURCE_DIR=$(realpath .) + +cd /sc/superconfigure +make o/janet/built.fat diff --git a/.github/cosmo/recipe.mk b/.github/cosmo/recipe.mk new file mode 100644 index 00000000..a49adaf4 --- /dev/null +++ b/.github/cosmo/recipe.mk @@ -0,0 +1,26 @@ +# this recipe is copied into superconfigure/janet/BUILD.mk +o/janet/downloaded: \ + DL_COMMAND = cp -r $(SOURCE_DIR) ./ && ls -al && ls -al .. + +o/janet/patched: PATCH_COMMAND = $(DUMMYLINK0) + +o/janet/configured.x86_64: \ + CONFIG_COMMAND = cp -r $(BASELOC)/o/janet/janet/* ./ + +o/janet/configured.aarch64: \ + CONFIG_COMMAND = cp -r $(BASELOC)/o/janet/janet/* ./ + +o/janet/built.x86_64: \ + BUILD_COMMAND = make PREFIX=$(COSMOS) HAS_SHARED=0 JANET_NO_AMALG=1 + +o/janet/built.aarch64: \ + BUILD_COMMAND = make PREFIX=$(COSMOS) HAS_SHARED=0 JANET_NO_AMALG=1 + +o/janet/installed.x86_64: \ + INSTALL_COMMAND = cp build/janet $(COSMOS)/bin/ + +o/janet/installed.aarch64: \ + INSTALL_COMMAND = cp build/janet $(COSMOS)/bin/ + +o/janet/built.fat: \ + BINS = janet diff --git a/.github/cosmo/setup b/.github/cosmo/setup new file mode 100644 index 00000000..ca7d0424 --- /dev/null +++ b/.github/cosmo/setup @@ -0,0 +1,28 @@ +#!/bin/sh +set -e + +sudo apt update +sudo apt-get install -y ca-certificates libssl-dev\ + qemu qemu-utils qemu-user-static\ + texinfo groff\ + cmake ninja-build bison zip\ + pkg-config build-essential autoconf re2c + +# clone superconfigure +cd /sc +git clone https://github.com/ahgamut/superconfigure --depth=1 --branch=z0.0.39 + +# the zip folder +sudo mkdir -p /zip +sudo chmod -R 0777 /zip + +# clone cosmo +cd /sc/superconfigure +git clone https://github.com/jart/cosmopolitan --depth=1 --branch=3.3.3 cosmopolitan +sudo cp cosmopolitan/build/bootstrap/ape.elf /usr/bin/ape +sudo sh -c "echo ':APE:M::MZqFpD::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register" +# ls /proc/sys/fs/binfmt_misc/ + +# build cosmo +cd /sc/superconfigure +./.github/scripts/cosmo diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b4b0f061..6d9d9ea2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,32 +67,20 @@ jobs: name: Build release binaries for Cosmo runs-on: ubuntu-latest steps: + - name: Checkout the repository + uses: actions/checkout@master - name: create build folder run: | sudo mkdir -p /sc sudo chmod -R 0777 /sc - - name: Checkout superconfigure repo - working-directory: /sc - run: git clone https://github.com/ahgamut/superconfigure - - name: support ape bins and SSL things - working-directory: /sc/superconfigure - run: bash ./.github/scripts/setup - - name: build Cosmo - working-directory: /sc/superconfigure - run: bash ./.github/scripts/cosmo - - name: clone Janet latest commit - working-directory: /sc/superconfigure - run: | - make o/lang/janet/downloaded - cd o/lang/janet/janet - git pull origin master + - name: setup Cosmopolitan Libc + run: bash ./.github/cosmo/setup - name: Set the version run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV - name: Set the platform run: echo "platform=cosmo" >> $GITHUB_ENV - name: build Janet APE binary - working-directory: /sc/superconfigure - run: make o/lang/janet/built.fat + run: bash ./.github/cosmo/build - name: push binary to github uses: softprops/action-gh-release@v1 with: From 382ff77bbe3eca82a99e7f5e12f84ceea65e8fde Mon Sep 17 00:00:00 2001 From: Gautham Date: Sat, 20 Apr 2024 22:16:23 -0500 Subject: [PATCH 07/13] typo --- .github/cosmo/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/cosmo/build b/.github/cosmo/build index 22c51c46..6c1f4087 100644 --- a/.github/cosmo/build +++ b/.github/cosmo/build @@ -3,7 +3,7 @@ # copy janet recipe mkdir -p /sc/sueprconfigure/janet cp ./.github/cosmo/recipe.mk /sc/superconfigure/BUILD.mk -cat 'include janet/BUILD.mk' >> /sc/superconfigure/custom.mk +echo 'include janet/BUILD.mk' >> /sc/superconfigure/custom.mk export SOURCE_DIR=$(realpath .) From 50425eac7228d29f9c7ee3a63a9d64a4212d2a2c Mon Sep 17 00:00:00 2001 From: Gautham Date: Sat, 20 Apr 2024 22:23:29 -0500 Subject: [PATCH 08/13] typo --- .github/cosmo/build | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/cosmo/build b/.github/cosmo/build index 6c1f4087..518e403e 100644 --- a/.github/cosmo/build +++ b/.github/cosmo/build @@ -1,11 +1,14 @@ #!/bin/sh +set -eux # copy janet recipe -mkdir -p /sc/sueprconfigure/janet -cp ./.github/cosmo/recipe.mk /sc/superconfigure/BUILD.mk +mkdir -p /sc/superconfigure/janet +cp ./.github/cosmo/recipe.mk /sc/superconfigure/janet/BUILD.mk echo 'include janet/BUILD.mk' >> /sc/superconfigure/custom.mk export SOURCE_DIR=$(realpath .) cd /sc/superconfigure +ls -al +cat custom.mk make o/janet/built.fat From eebb4c3ade3c468fb1249f885d8eb46740766477 Mon Sep 17 00:00:00 2001 From: Gautham Date: Sat, 20 Apr 2024 22:35:04 -0500 Subject: [PATCH 09/13] remove logging --- .github/cosmo/build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/cosmo/build b/.github/cosmo/build index 518e403e..e2a301c5 100644 --- a/.github/cosmo/build +++ b/.github/cosmo/build @@ -6,9 +6,7 @@ mkdir -p /sc/superconfigure/janet cp ./.github/cosmo/recipe.mk /sc/superconfigure/janet/BUILD.mk echo 'include janet/BUILD.mk' >> /sc/superconfigure/custom.mk +# build janet with cosmopolitan libc export SOURCE_DIR=$(realpath .) - cd /sc/superconfigure -ls -al -cat custom.mk make o/janet/built.fat From 983c2e5499a70834af08265645023affa532cb4d Mon Sep 17 00:00:00 2001 From: Gautham Date: Sun, 21 Apr 2024 01:10:06 -0500 Subject: [PATCH 10/13] simplify build to use only cosmocc --- .github/cosmo/build | 42 ++++++++++++++++++++++++++++++++++-------- .github/cosmo/setup | 23 ++++++++--------------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/.github/cosmo/build b/.github/cosmo/build index e2a301c5..3b385ca8 100644 --- a/.github/cosmo/build +++ b/.github/cosmo/build @@ -1,12 +1,38 @@ #!/bin/sh set -eux -# copy janet recipe -mkdir -p /sc/superconfigure/janet -cp ./.github/cosmo/recipe.mk /sc/superconfigure/janet/BUILD.mk -echo 'include janet/BUILD.mk' >> /sc/superconfigure/custom.mk +COSMO_DIR="/sc/cosmocc" -# build janet with cosmopolitan libc -export SOURCE_DIR=$(realpath .) -cd /sc/superconfigure -make o/janet/built.fat +# build x86_64 +X86_64_CC="/sc/cosmocc/bin/x86_64-unknown-cosmo-cc" +X86_64_AR="/sc/cosmocc/bin/x86_64-unknown-cosmo-ar" +mkdir -p /sc/cosmocc/x86_64 +make CC="$X86_64_CC" AR="$X86_64_AR" HAS_SHARED=0 JANET_NO_AMALG=1 +cp build/janet /sc/cosmocc/x86_64/janet +make clean + +# build aarch64 +AARCH64_CC="/sc/cosmocc/bin/aarch64-unknown-cosmo-cc" +AARCH64_AR="/sc/cosmocc/bin/aarch64-unknown-cosmo-ar" +mkdir -p /sc/cosmocc/arch64 +make CC="$AARCH64_CC" AR="$AARCH64_AR" HAS_SHARED=0 JANET_NO_AMALG=1 +cp build/janet /sc/cosmocc/aarch64/janet +make clean + +# fat binary +apefat () { + OUTPUT="$1" + OLDNAME_X86_64="$(basename -- "$2")" + OLDNAME_AARCH64="$(basename -- "$3")" + TARG_FOLD="$(dirname "$OUTPUT")" + "$APELINK" -l "$COSMO_DIR/bin/ape-x86_64.elf" \ + -l "$COSMO_DIR/bin/ape-aarch64.elf" \ + -M "$COSMO_DIR/bin/ape-m1.c" \ + -o "$OUTPUT" \ + "$2" \ + "$3" + cp "$2" "$TARG_FOLD/$OLDNAME_X86_64.x86_64" + cp "$3" "$TARG_FOLD/$OLDNAME_AARCH64.aarch64" +} + +apefat ./janet.com /sc/cosmocc/x86_64/janet /sc/cosmocc/aarch64/janet diff --git a/.github/cosmo/setup b/.github/cosmo/setup index ca7d0424..9de92d41 100644 --- a/.github/cosmo/setup +++ b/.github/cosmo/setup @@ -8,21 +8,14 @@ sudo apt-get install -y ca-certificates libssl-dev\ cmake ninja-build bison zip\ pkg-config build-essential autoconf re2c -# clone superconfigure +# download cosmocc cd /sc -git clone https://github.com/ahgamut/superconfigure --depth=1 --branch=z0.0.39 +wget https://github.com/jart/cosmopolitan/releases/download/3.3.3/cosmocc-3.3.3.zip +mkdir -p cosmocc +cd cosmocc +unzip ../cosmocc-3.3.3.zip -# the zip folder -sudo mkdir -p /zip -sudo chmod -R 0777 /zip - -# clone cosmo -cd /sc/superconfigure -git clone https://github.com/jart/cosmopolitan --depth=1 --branch=3.3.3 cosmopolitan -sudo cp cosmopolitan/build/bootstrap/ape.elf /usr/bin/ape +# register +cd /sc/cosmocc +sudo cp ./bin/ape-x86_64.elf /usr/bin/ape sudo sh -c "echo ':APE:M::MZqFpD::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register" -# ls /proc/sys/fs/binfmt_misc/ - -# build cosmo -cd /sc/superconfigure -./.github/scripts/cosmo From 3f40c8d7fba70742e3ace768ddf62e2f5e5c01ea Mon Sep 17 00:00:00 2001 From: Gautham Date: Sun, 21 Apr 2024 01:12:59 -0500 Subject: [PATCH 11/13] fix typo --- .github/cosmo/build | 8 ++++---- .github/workflows/release.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/cosmo/build b/.github/cosmo/build index 3b385ca8..a9515c35 100644 --- a/.github/cosmo/build +++ b/.github/cosmo/build @@ -7,15 +7,15 @@ COSMO_DIR="/sc/cosmocc" X86_64_CC="/sc/cosmocc/bin/x86_64-unknown-cosmo-cc" X86_64_AR="/sc/cosmocc/bin/x86_64-unknown-cosmo-ar" mkdir -p /sc/cosmocc/x86_64 -make CC="$X86_64_CC" AR="$X86_64_AR" HAS_SHARED=0 JANET_NO_AMALG=1 +make -j CC="$X86_64_CC" AR="$X86_64_AR" HAS_SHARED=0 JANET_NO_AMALG=1 cp build/janet /sc/cosmocc/x86_64/janet make clean # build aarch64 AARCH64_CC="/sc/cosmocc/bin/aarch64-unknown-cosmo-cc" AARCH64_AR="/sc/cosmocc/bin/aarch64-unknown-cosmo-ar" -mkdir -p /sc/cosmocc/arch64 -make CC="$AARCH64_CC" AR="$AARCH64_AR" HAS_SHARED=0 JANET_NO_AMALG=1 +mkdir -p /sc/cosmocc/aarch64 +make -j CC="$AARCH64_CC" AR="$AARCH64_AR" HAS_SHARED=0 JANET_NO_AMALG=1 cp build/janet /sc/cosmocc/aarch64/janet make clean @@ -35,4 +35,4 @@ apefat () { cp "$3" "$TARG_FOLD/$OLDNAME_AARCH64.aarch64" } -apefat ./janet.com /sc/cosmocc/x86_64/janet /sc/cosmocc/aarch64/janet +apefat /sc/cosmocc/janet.com /sc/cosmocc/x86_64/janet /sc/cosmocc/aarch64/janet diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d9d9ea2..4c19750b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,4 +86,4 @@ jobs: with: draft: true files: | - /sc/superconfigure/results/bin/janet.com + /sc/cosmocc/janet.com From 71a123fef7ff48d4dd37bd5c1778acab8f5530ea Mon Sep 17 00:00:00 2001 From: Gautham Date: Sun, 21 Apr 2024 01:14:58 -0500 Subject: [PATCH 12/13] apelink --- .github/cosmo/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/cosmo/build b/.github/cosmo/build index a9515c35..0c7f010b 100644 --- a/.github/cosmo/build +++ b/.github/cosmo/build @@ -25,7 +25,7 @@ apefat () { OLDNAME_X86_64="$(basename -- "$2")" OLDNAME_AARCH64="$(basename -- "$3")" TARG_FOLD="$(dirname "$OUTPUT")" - "$APELINK" -l "$COSMO_DIR/bin/ape-x86_64.elf" \ + "$COSMO_DIR/bin/apelink" -l "$COSMO_DIR/bin/ape-x86_64.elf" \ -l "$COSMO_DIR/bin/ape-aarch64.elf" \ -M "$COSMO_DIR/bin/ape-m1.c" \ -o "$OUTPUT" \ From d0d551d73930368d0ed27058bfdc246d6aa01ca2 Mon Sep 17 00:00:00 2001 From: Gautham Date: Sun, 21 Apr 2024 01:16:54 -0500 Subject: [PATCH 13/13] remove superconfigure recipe --- .github/cosmo/recipe.mk | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/cosmo/recipe.mk diff --git a/.github/cosmo/recipe.mk b/.github/cosmo/recipe.mk deleted file mode 100644 index a49adaf4..00000000 --- a/.github/cosmo/recipe.mk +++ /dev/null @@ -1,26 +0,0 @@ -# this recipe is copied into superconfigure/janet/BUILD.mk -o/janet/downloaded: \ - DL_COMMAND = cp -r $(SOURCE_DIR) ./ && ls -al && ls -al .. - -o/janet/patched: PATCH_COMMAND = $(DUMMYLINK0) - -o/janet/configured.x86_64: \ - CONFIG_COMMAND = cp -r $(BASELOC)/o/janet/janet/* ./ - -o/janet/configured.aarch64: \ - CONFIG_COMMAND = cp -r $(BASELOC)/o/janet/janet/* ./ - -o/janet/built.x86_64: \ - BUILD_COMMAND = make PREFIX=$(COSMOS) HAS_SHARED=0 JANET_NO_AMALG=1 - -o/janet/built.aarch64: \ - BUILD_COMMAND = make PREFIX=$(COSMOS) HAS_SHARED=0 JANET_NO_AMALG=1 - -o/janet/installed.x86_64: \ - INSTALL_COMMAND = cp build/janet $(COSMOS)/bin/ - -o/janet/installed.aarch64: \ - INSTALL_COMMAND = cp build/janet $(COSMOS)/bin/ - -o/janet/built.fat: \ - BINS = janet