Created
          September 2, 2025 02:13 
        
      - 
      
 - 
        
Save willnode/4cc8cc07359eca874baa97dd795ccd24 to your computer and use it in GitHub Desktop.  
    Generate Go Types for Redox OS, see https://github.com/willnode/go
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # A script to generate Redox syscalls in Go source files, put this script to "src" folder | |
| # You must have Redox build system in $HOME/redox with "prefix" generated | |
| # You must have "$ARCH-unknown-redox-gcc" in your PATH, add it from Redox build system | |
| # mkerrors: You need to patch "$CC" to "gcc" at the bottom of the script, also "$(uname)" to "Redox" | |
| # mkerrors: You need to comment out "#include <netinet/ip6.h>" and "#include <sys/signal.h>" since Redox doesn't have it | |
| export ARCH=x86_64 GOARCH=amd64 # intentionally not setting GOOS since "go" run on vanilla Go | |
| export redox_sysroot="$HOME/redox/prefix/$ARCH-unknown-redox/sysroot/$ARCH-unknown-redox" | |
| export CGO_FLAGS="--sysroot=${redox_sysroot}" \ | |
| CC=$ARCH-unknown-redox-gcc TARGET=$ARCH-unknown-redox GNU_TARGET=$ARCH-unknown-redox \ | |
| CFLAGS="-I${redox_sysroot}/include" | |
| cd syscall | |
| go tool cgo -godefs types_redox.go | go run mkpost.go > ztypes_redox_$GOARCH.go | |
| ./mksyscall_libc.pl -redox -tags redox,$GOARCH syscall_redox.go > zsyscall_redox_$GOARCH.go | |
| bash ./mkerrors.sh > zerrors_redox_$GOARCH.go | |
| cd .. | |
| cd cmd/vendor/golang.org/x/sys/unix | |
| (GOOS=redox bash ./mkerrors.sh > zerrors_redox_$GOARCH.go) | |
| sed -i s/sizeOf/SizeOf/g zerrors_redox_$GOARCH.go | |
| cd ../../../../../.. | |
| cd runtime | |
| # prefixed with ~, see https://github.com/golang/go/issues/23341 | |
| # we have to make it as close as possible by our hand :( | |
| go tool cgo -godefs defs_redox.go > defs_redox_$GOARCH.go~ | |
| cd .. | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment