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

Add support for NetBSD #268

Merged
merged 61 commits into from
Mar 8, 2025

Conversation

TotallyGamerJet
Copy link
Collaborator

@TotallyGamerJet TotallyGamerJet commented Aug 18, 2024

What issue is this addressing?

Close #249

What type of issue is this addressing?

feature

What this PR does | solves

Allows cross/compiling with purego on NetBSD

@TotallyGamerJet
Copy link
Collaborator Author

@0-wiz-0 I'm trying to finish up this PR so it can be merged but I can't figure out how to install go in the NetBSD environment. Could you look at the test.yml file?

@0-wiz-0
Copy link

0-wiz-0 commented Oct 15, 2024

Thank you for working on this, @TotallyGamerJet !
I looked at test.yml. You are using the upstream go binaries. They are distributed in a standard tarball, not as a pkgsrc package, so just unpack the tarball and use it - do not use pkg_add.
A prepare step like this should probably work:

          prepare: |
            ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz
            rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz
            ln -s /usr/local/go/bin/go /usr/local/bin

(Btw, cross-compilation to NetBSD should also work as usual in go.)

@TotallyGamerJet
Copy link
Collaborator Author

TotallyGamerJet commented Oct 15, 2024

Thanks for the help. I'm getting some weird error when opening the archive. Thoughts?

(Btw, cross-compilation to NetBSD should also work as usual in go.)

This PR currently only supports Cgo. Once I get it in a usable state I can work on getting the entirely go version working which would enable cross compiling

@0-wiz-0
Copy link

0-wiz-0 commented Oct 15, 2024

I see:

 ln -s /usr/local/go/bin/go /usr/local/bin
  /usr/bin/bash /home/runner/work/_actions/vmactions/netbsd-vm/v1/run.sh execSSHSH
  Config file: netbsd-10.0.conf
  FFFFFFFFFFFFFFFF:error:0A000126:SSL routines:ssl3_read_n:unexpected eof while reading:/usr/src/crypto/external/bsd/openssl/dist/ssl/record/rec_layer_s3.c:303:

you can ignore this, it's a bogus warning that will be fixed in 10.1.

  tar: could not chdir to '/usr/local'
  
  ln: /usr/local/bin: No such file or directory

Seems we need to add

mkdir /usr/local

before the tar command.
I didn't know that the target directory needed to exist first, sorry.

@TotallyGamerJet
Copy link
Collaborator Author

It's definitely there! Why doesn't it see it?

export PATH=$PATH:/usr/local/go/bin/

chmod +x .github/scripts/bsd_tests.sh
run: bash .github/scripts/bsd_tests.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already in a vm? In this case, shouldn't we copy the bsd_test.sh into the vm?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repo is checked out which includes the bsd_tests.sh file. There isn't a need to copy it I don't think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the .github folder though in that ls call

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok it looks like it's not there at least in FreeBSD

.
  ..
  .cshrc
  .k5login
  .login
  .profile
  .sh_history
  .shrc
  .ssh
  go1.20.14.freebsd-amd64.tar.gz
  work
  
  ./.ssh:
  .
  ..
  authorized_keys
  config
  id_rsa
  id_rsa.pub
  known_hosts
  chmod: .github/scripts/bsd_tests.sh: No such file or directory

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but what about $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closer now since some of the NetBSD ones passed. FreeBSD still failed tho

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, $GITHUB_WORKSPACE seems empty now...

@@ -0,0 +1,79 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If bash command is not found, does this work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to use bash, we need to specify the correct path (/usr/bin/bash or /usr/local/bin/bash? I don't know...)


# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2025 The Ebitengine Authors

Copy link
Member

@hajimehoshi hajimehoshi Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add set -e to abort this script whenever any command fails.

EDIT: Hmm this might work only with Bash.

@hajimehoshi
Copy link
Member

@hajimehoshi
Copy link
Member

Maybe we can use regular actions? I don't know... https://github.com/vmactions/netbsd-vm?tab=readme-ov-file#7-custom-shell

@hajimehoshi
Copy link
Member

hajimehoshi commented Mar 8, 2025

https://github.com/hajimehoshi/purego/actions/runs/13740503731/job/38429163182 Mine worked. Feel free to copy it.

diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh
index 6bbc34b..fb1c51e 100755
--- a/.github/scripts/bsd_tests.sh
+++ b/.github/scripts/bsd_tests.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # SPDX-License-Identifier: Apache-2.0
 # SPDX-FileCopyrightText: 2025 The Ebitengine Authors
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 6e4b92c..257decf 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -149,7 +149,8 @@ jobs:
       run:
         shell: bash
     steps:
-      - uses: actions/checkout@v4
+      - name: Chckout
+        uses: actions/checkout@v4
       - name: Run in freebsd
         if: matrix.os == 'FreeBSD'
         uses: vmactions/freebsd-vm@v1
@@ -159,11 +160,8 @@ jobs:
             fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz
             rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz
             ln -s /usr/local/go/bin/go /usr/local/bin
-            ls -a -R
             chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
-          run: |
-            ls -a -R
-            $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
+          run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
       - name: Run in netbsd
         # there are no prebuilt download links for these versions of Go for NetBSD
         if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.')

The points are:

  • $GITHUB_WORKSPACE is available.
  • Bash doesn't exist in VMs.
  • Use #!/bin/sh for shebangs.
  • Run script by just specifying the file name directly.

@hajimehoshi
Copy link
Member

hajimehoshi commented Mar 8, 2025

Ugh, this might not work well.. I'm investigating now.

An experimental version hajimehoshi@fc9e26c passed the test, but hajimehoshi@420b528 doesn't. Why...??

@hajimehoshi
Copy link
Member

hajimehoshi commented Mar 8, 2025

https://github.com/hajimehoshi/purego/actions/runs/13740761223/job/38429706509 OK, exporting PATH doesn't work in separate items. Now this change worked!

diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh
index fb1c51e..1c5b9d2 100755
--- a/.github/scripts/bsd_tests.sh
+++ b/.github/scripts/bsd_tests.sh
@@ -10,6 +10,8 @@
 
 echo "Running tests on $(uname -a) at $PWD"
 
+PATH=$PATH:/usr/local/go/bin
+
 # verify Go is available
 go version
 
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f660bb2..205c3ab 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -149,7 +149,8 @@ jobs:
       run:
         shell: bash
     steps:
-      - uses: actions/checkout@v4
+      - name: Checkout
+        uses: actions/checkout@v4
       - name: Run in freebsd
         if: matrix.os == 'FreeBSD'
         uses: vmactions/freebsd-vm@v1
@@ -158,7 +159,6 @@ jobs:
           prepare: |
             fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz
             rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz
-            ln -s /usr/local/go/bin/go /usr/local/bin
             chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
           run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
       - name: Run in netbsd
@@ -172,7 +172,5 @@ jobs:
             ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz
             mkdir /usr/local
             rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz
-            ln -s /usr/local/go/bin/go /usr/local/bin
-            export PATH=$PATH:/usr/local/go/bin/
             chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
           run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh

@TotallyGamerJet TotallyGamerJet merged commit 1bd362f into ebitengine:main Mar 8, 2025
35 checks passed
@TotallyGamerJet TotallyGamerJet deleted the issue-249_netbsd branch March 8, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for NetBSD
3 participants