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

Cannot compile for FreeBSD #4516

Closed
Tracked by #5054
unknowndevQwQ opened this issue Oct 12, 2022 · 20 comments
Closed
Tracked by #5054

Cannot compile for FreeBSD #4516

unknowndevQwQ opened this issue Oct 12, 2022 · 20 comments
Labels
chore Non-customer facing refactors, cleanup, or technical debt. feature Something we don't have yet

Comments

@unknowndevQwQ
Copy link
Contributor

coder currently has no binaries for freebsd, tried to compile one but got an error

Steps to reproduce

  1. git clone github.com/coder/coder (commit abf14d9)
  2. run scripts/build_go.sh --os freebsd --arch amd64 --agpl

output:

# github.com/u-root/u-root/pkg/termios
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/sgtty_unix.go:13:20: undefined: unix.TCGETS
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/sgtty_unix.go:14:20: undefined: unix.TCSETS
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/termios.go:33:10: undefined: TTYIO
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/termios.go:39:9: undefined: MakeRaw
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/termios.go:48:10: undefined: TTYIO
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/termios.go:71:10: undefined: TTYIO
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/termios.go:75:10: undefined: TTYIO
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/var_unix.go:42:38: undefined: syscall.IUTF8
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/var_unix.go:50:37: undefined: syscall.OFILL
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/var_unix.go:51:37: undefined: syscall.OFDEL
../../go/pkg/mod/github.com/u-root/u-root@v0.9.0/pkg/termios/termios.go:39:9: too many errors
# github.com/godbus/dbus/v5
../../go/pkg/mod/github.com/godbus/dbus/v5@v5.1.0/transport_unix.go:52:10: cannot use t (variable of type *unixTransport) as type transport in return statement:
        *unixTransport does not implement transport (missing SendNullByte method)
../../go/pkg/mod/github.com/godbus/dbus/v5@v5.1.0/transport_unix.go:58:10: cannot use t (variable of type *unixTransport) as type transport in return statement:
        *unixTransport does not implement transport (missing SendNullByte method)
@kylecarbs kylecarbs changed the title Compile error when compiling for freebsd in linux Cannot compile for FreeBSD Oct 12, 2022
@kylecarbs kylecarbs added feature Something we don't have yet chore Non-customer facing refactors, cleanup, or technical debt. labels Oct 12, 2022
@kylecarbs
Copy link
Member

It seems like this would require some relatively significant changes. Do you need to run on FreeBSD?

@unknowndevQwQ
Copy link
Contributor Author

It seems like this would require some relatively significant changes. Do you need to run on FreeBSD?

yep

@ghuntley
Copy link
Contributor

ghuntley commented Nov 7, 2022

yep

Is this for your homelab or at work btw @unknowndevQwQ? Would love to know more about your particular use case.

Are you provisioning freebsd infrastructure or are you wanting to run the coder portal on freebsd.

@ghuntley
Copy link
Contributor

ghuntley commented Nov 8, 2022

I spun up a FreeBSD virtual machine to dig a little deeper - here are my notes:

  1. Install src, ports and debug (inc x86)
  2. Install git
$ pkg update -f
$ pkg install git
  1. Clone source code
$ git clone https://github.com/coder/coder.git --recursive
  1. Install dependencies
$ pkg install bash getopt docker docker-machine go shfmt node nfpm zstd pkgconf pixman cairo pango 
$ cd /usr/ports/textproc/hs-pandoc/ && make install clean
  1. Must use /usr/local/bin/getopt instead of /usr/bin/getopt
  2. Must use gmake not make
diff --git a/scripts/lib.sh b/scripts/lib.sh
index 67922db3..d7b1d2b0 100644
--- a/scripts/lib.sh
+++ b/scripts/lib.sh
@@ -149,7 +149,7 @@ if [[ "${CODER_LIBSH_NO_CHECK_DEPENDENCIES:-}" != *t* ]]; then
        fi
 
        # BSD getopt (which is installed by default on Macs) is not supported.
-       if [[ "$(getopt --version)" == *--* ]]; then
+       if [[ "$(/usr/local/bin/getopt --version)" == *--* ]]; then
                libsh_bad_dependencies=1
                log "ERROR: You need GNU getopt to run the scripts in the Coder repo."
                if isdarwin; then

diff --git a/scripts/build_go.sh b/scripts/build_go.sh
index 3a864989..ad23b991 100755
--- a/scripts/build_go.sh
+++ b/scripts/build_go.sh
@@ -35,7 +35,7 @@ sign_darwin="${CODER_SIGN_DARWIN:-0}"
 output_path=""
 agpl="${CODER_BUILD_AGPL:-0}"
 
-args="$(getopt -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin -- "$@")"
+args="$(/usr/local/bin/getopt -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin -- "$@")"
 eval set -- "$args"
 while true; do
        case "$1" in
  1. Build with scripts/build_go.sh --os freebsd --arch amd64 --agpl
  2. Build failure as follows
go: downloading github.com/gobwas/glob v0.2.3
go: downloading github.com/tchap/go-patricia/v2 v2.3.1
go: downloading github.com/yashtewari/glob-intersection v0.1.0
go: downloading github.com/mitchellh/go-ps v1.0.0
go: downloading github.com/bep/godartsass v0.14.0
go: downloading github.com/bep/golibsass v1.1.0
go: downloading github.com/tdewolff/parse/v2 v2.6.4
go: downloading github.com/hashicorp/go-cleanhttp v0.5.2
go: downloading github.com/google/go-cmp v0.5.9
go: downloading github.com/x448/float16 v0.8.4
go: downloading filippo.io/edwards25519 v1.0.0-rc.1
go: downloading github.com/agnivade/levenshtein v1.1.1



# github.com/u-root/u-root/pkg/termios
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/sgtty_unix.go:13:20: undefined: unix.TCGETS
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/sgtty_unix.go:14:20: undefined: unix.TCSETS
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:33:10: undefined: TTYIO
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:39:9: undefined: MakeRaw
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:48:10: undefined: TTYIO
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:71:10: undefined: TTYIO
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:75:10: undefined: TTYIO
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:42:38: undefined: syscall.IUTF8
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:50:37: undefined: syscall.OFILL
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:51:37: undefined: syscall.OFDEL
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:39:9: too many errors
# github.com/godbus/dbus/v5
/root/go/pkg/mod/github.com/godbus/dbus/v5@v5.1.0/transport_unix.go:52:10: cannot use t (variable of type *unixTransport) as type transport in return statement:
        *unixTransport does not implement transport (missing SendNullByte method)
/root/go/pkg/mod/github.com/godbus/dbus/v5@v5.1.0/transport_unix.go:58:10: cannot use t (variable of type *unixTransport) as type transport in return statement:
        *unixTransport does not implement transport (missing SendNullByte method)

@ghuntley

This comment was marked as outdated.

@koobs
Copy link

koobs commented Nov 8, 2022

Hi Geoffrey,

This looks like: godbus/dbus#237

See Also:

See Also Also:

@guelfey may be able to provide advice for the best path to resolve, cc @buglloc and our @dfr (working on godbus/dbus#332)

@gjake1337
Copy link

gjake1337 commented Nov 8, 2022

@ghuntley Hey just curious, what does your rc.conf file look like for the FreeBSD machine?

Edit:
I was wondering if you had dbus enabled or not
dbus_enable="YES"
Might not be relevant idk.

@ghuntley
Copy link
Contributor

ghuntley commented Nov 8, 2022

@ghuntley Hey just curious, what does your rc.conf file look like for the FreeBSD machine?

👋 @gjake1337

root@freebsd:~ # pkg install dbus
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        dbus: 1.14.4,1
        libICE: 1.0.10,1
        libSM: 1.2.3,1

Number of packages to be installed: 3

The process will require 2 MiB more space.
499 KiB to be downloaded.

Proceed with this action? [y/N]: y
[1/3] Fetching dbus-1.14.4,1.pkg: 100%  383 KiB 392.2kB/s    00:01    
[2/3] Fetching libICE-1.0.10,1.pkg: 100%   92 KiB  94.5kB/s    00:01    
[3/3] Fetching libSM-1.2.3,1.pkg: 100%   24 KiB  24.2kB/s    00:01    
Checking integrity... done (0 conflicting)
[1/3] Installing libICE-1.0.10,1...
[1/3] Extracting libICE-1.0.10,1: 100%
[2/3] Installing libSM-1.2.3,1...
[2/3] Extracting libSM-1.2.3,1: 100%
[3/3] Installing dbus-1.14.4,1...
===> Creating groups.
Creating group 'messagebus' with gid '556'.
===> Creating users
Creating user 'messagebus' with uid '556'.
[3/3] Extracting dbus-1.14.4,1: 100%
root@freebsd:/coder # cat /etc/rc.conf
hostname="freebsd"
ifconfig_vtnet0="DHCP"
ifconfig_vtnet0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"

dbus_enable="YES"
root@freebsd:/coder # service dbus start
Starting dbus.
root@freebsd:/coder # scripts/build_go.sh --os freebsd --arch amd64 --agpl
# github.com/u-root/u-root/pkg/termios
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/sgtty_unix.go:13:20: undefined: unix.TCGETS
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/sgtty_unix.go:14:20: undefined: unix.TCSETS
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:33:10: undefined: TTYIO
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:39:9: undefined: MakeRaw
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:48:10: undefined: TTYIO
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:71:10: undefined: TTYIO
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:75:10: undefined: TTYIO
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:42:38: undefined: syscall.IUTF8
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:50:37: undefined: syscall.OFILL
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:51:37: undefined: syscall.OFDEL
/root/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:39:9: too many errors
# github.com/godbus/dbus/v5
/root/go/pkg/mod/github.com/godbus/dbus/v5@v5.1.0/transport_unix.go:52:10: cannot use t (variable of type *unixTransport) as type transport in return statement:
        *unixTransport does not implement transport (missing SendNullByte method)
/root/go/pkg/mod/github.com/godbus/dbus/v5@v5.1.0/transport_unix.go:58:10: cannot use t (variable of type *unixTransport) as type transport in return statement:
        *unixTransport does not implement transport (missing SendNullByte method)

@dfr
Copy link

dfr commented Nov 8, 2022 via email

@unknowndevQwQ
Copy link
Contributor Author

unknowndevQwQ commented Nov 8, 2022

Is this for your homelab or at work btw @unknowndevQwQ? Would love to know more about your particular use case.

homelab

Are you provisioning freebsd infrastructure or are you wanting to run the coder portal on freebsd.

Run coder on freebsd and try to connect to freebsd using vscode remote via coder

@ghuntley
Copy link
Contributor

Some updates

Thanks to https://twitter.com/koobs aka @koobs we have been able to get a binary to compile. It's the weekend rn so later can explore topics of validation if there's anything else left to do.

CleanShot 2022-11-12 at 11 47 15@2x

@koobs
Copy link

koobs commented Nov 12, 2022

Note also the build is all from sources (no packages for dependencies), so we're a step ahead of a future FreeBSD Port/Package

Edit: (2022-11-14) Patch link above is temporarily unavailable. Had a little power outage last night causing a zfs import issue.

@koobs
Copy link

koobs commented Dec 6, 2022

Hey all! Please find attached a patch set adding FreeBSD support to Coder.

Apologies for the patch set over a PR, as I lost my local dev environment configurations to filesystem failure. Apologies also for the *.txt filenames, but GitHub doesn't allow *.patch files currently :)

0001-Update-godbus-dependency-to-latest.txt
0002-Allow-overriding-getopt-from-the-environment.txt
0003-Allow-specifying-go-command-from-the-environment.txt
0004-Allow-specifying-make-command-via-environment.txt
0005-Fix-variable-assignments-and-usage.txt
0006-Update-termios-u-root-dependency.txt
0007-coderd-tz-Add-FreeBSD-tz-support.txt

This has been tested from deployment setup using a local PostgreSQL (15) server, through to templates init which returns a list of currently supported operating environments. See screenshot below:

sshot-2022-12-06-09-55-18

ghuntley pushed a commit that referenced this issue Dec 7, 2022
Coder fails to build [1] on FreeBSD:

transport_unix.go:52:10: cannot use t (variable of type *unixTransport) as type transport in return statement:
        *unixTransport does not implement transport (missing SendNullByte method)

Update godbus dependency to latest, post upstream PR #332 [2] via #237

Fixes: #4516

[1] #4516
[2] godbus/dbus#332
[3] godbus/dbus#237
ghuntley pushed a commit that referenced this issue Dec 7, 2022
`./scripts/build_go.sh --os freebsd` fails to build with the following
(unique) errors:

  termios/sgtty_unix.go:13:20: undefined: unix.TCGETS
  termios/termios.go:33:10: undefined: TTYIO
  termios/termios.go:39:9: undefined: MakeRaw
  termios/var_unix.go:42:38: undefined: syscall.IUTF8
  termios/var_unix.go:50:37: undefined: syscall.OFILL
  termios/var_unix.go:51:37: undefined: syscall.OFDEL

This was resolved upstream in u-root/u-root/pull/2544 [1]
via tailscale/tailscale/pull/6155 [2] in u-root/u-root/commit/18fd0ce36 [3]

Update termios (u-root) dependency to a commit just past that
change.

[1] u-root/u-root#2544
[2] tailscale/tailscale#6155
[3] u-root/u-root@18fd0ce36

Fixes: #4516
ghuntley pushed a commit that referenced this issue Dec 7, 2022
`./scripts/build_go.sh --os freebsd` fails to build with the following
(unique) errors:

  cli/schedule.go:223:19: undefined: tz.TimezoneIANA
  cli/util.go:116:17: undefined: tz.TimezoneIANA

coderd/util/tz currently contains per-OS implementions (one file per supported
OS), but is missing a tz_freebsd.go.

Follow the existing pattern by creating a tz_freebsd.go from tz_linux.go.

FreeBSD supports standard IANA zoneinfo (and /etc/localtime), so no other
changes are required.

Fixes: #4516
@github-actions
Copy link

github-actions bot commented May 2, 2023

This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity.

@github-actions github-actions bot added the stale This issue is like stale bread. label May 2, 2023
@koobs
Copy link

koobs commented May 2, 2023

Unstale

@github-actions github-actions bot removed the stale This issue is like stale bread. label May 3, 2023
@matifali
Copy link
Collaborator

Hi @koobs, Feel free to submit a PR.

@github-actions github-actions bot added the stale This issue is like stale bread. label Jan 15, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
@unknowndevQwQ
Copy link
Contributor Author

@matifali Please reopen this issue, it has not yet been resolved.

@matifali matifali reopened this Jan 23, 2024
@github-actions github-actions bot removed the stale This issue is like stale bread. label Jan 24, 2024
@sreya
Copy link
Collaborator

sreya commented Apr 4, 2024

We have no plans to do this ourselves but we're open to PRs from the community, I'm closing this as not planned for now

@unknowndevQwQ
Copy link
Contributor Author

We have no plans to do this ourselves but we're open to PRs from the community, I'm closing this as not planned for now

Why not keep this issue open?

@sreya
Copy link
Collaborator

sreya commented Apr 5, 2024

We're trying to keep the issue tracker focused so that it is easier for us to address the features and enhancements in the short and medium term. It doesn't appear as if there's been a lot of interest from the community since this was opened roughly a year and a half ago, but if that changes I'll happily open it back up and see where we can fit it in.

@sreya sreya closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Non-customer facing refactors, cleanup, or technical debt. feature Something we don't have yet
Projects
None yet
Development

No branches or pull requests

9 participants