Skip to content

Commit

Permalink
tinygo: enable cmd/core/init
Browse files Browse the repository at this point in the history
Add conditional compilation to exclude any use of network packages for
now. Further, `klauspost/zstd` is used, so to build this cmdlet with
tinygo requires to set the build tag `noasm` as well:

```
tinygo build -tags noasm .
```

Signed-off-by: leongross <[email protected]>
  • Loading branch information
leongross authored and rminnich committed Aug 9, 2024
1 parent b7dc420 commit f0c78d0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cmds/core/init/fns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !tinygo && (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris)
// +build !tinygo
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux netbsd openbsd solaris

package main
Expand Down
3 changes: 3 additions & 0 deletions pkg/libinit/net_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build linux && !tinygo
// +build linux,!tinygo

package libinit

import (
Expand Down
21 changes: 21 additions & 0 deletions pkg/libinit/net_linux_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2014-2019 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build linux && tinygo
// +build linux,tinygo

package libinit

import (
"github.com/u-root/u-root/pkg/ulog"
)

// Stub for notifying the user that network functionality is not supported on linux platforms
func linuxNetInit() {
ulog.KernelLog.Printf("tinygo builds currently do not support network functionality on linux platforms\n")
}

func init() {
osNetInit = linuxNetInit
}

0 comments on commit f0c78d0

Please sign in to comment.