Source builds on wsl

46 views
Skip to first unread message

R Z

unread,
Jan 10, 2022, 5:30:12 PM1/10/22
to cosmopolitan cosmonauts
Hello all, happy new year! Has anybody tried to build cosmopolitan from source on wsl? I'm running ubuntu 20.04 lts on wsl2.

I get the following complaint from windows about attempting to run a 16 bit application:

cosmomakeerr.PNG

Once I press ok, cosmopolitan is recommending me to do the following:

ERROR

  Thompson Shell Backwards Compatibility Issue Detected

DETAILS

  Actually Portable Executable assumes stock Linux configuration.
  Normal behavior is non-ELF files with x bit are run by /bin/sh.
  Linux lets people globally define arbitrary magic interpreters.
  Your computer couldve been tuned to run MZ scripts inside WINE.
  So if you use binfmt_misc you need to explicitly register this.

WORKAROUND

  sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register"

SEE ALSO

  https://justine.storage.googleapis.com/ape.html

Terminated


Any help would be greatly appreciated!

Regards,
Richie

R Z

unread,
Jan 10, 2022, 5:31:38 PM1/10/22
to cosmopolitan cosmonauts
I forgot to mention, the suggested workaround doesn't remediate the issue, the same prompt from windows appears.
Regards,
Richie
Message has been deleted

R Z

unread,
Jan 11, 2022, 8:10:52 PM1/11/22
to cosmopolitan cosmonauts
After running 
$echo 0 > /proc/sys/fs/binfmt_misc/WSLInterop
I can get past the sanity check however I run into the following isssue

`make MODE=tiny -j8 o/tiny/libc/stubs/stubs.a.pkg` exited with 161:
build/bootstrap/package.com -o o/tiny/libc/stubs/stubs.a.pkg o/tiny/libc/stubs/instrumentation.o o/tiny/libc/stubs/stackguard.o o/tiny/libc/stubs/xnu.o o/tiny/libc/stubs/debugbreak.o o/tiny/libc/stubs/assertfail.o o/tiny/libc/stubs/typeinfo.o o/tiny/libc/stubs/gcov.o o/tiny/libc/stubs/panic.o o/tiny/libc/stubs/stackchkguard.o o/tiny/libc/stubs/abort.o o/tiny/libc/stubs/cxapurevirtual.o o/tiny/libc/stubs/retpoline.o o/tiny/libc/stubs/ld.o

also, following the steps in the cosmopolitan intro on https://justine.lol/cosmopolitan/index.html doesn't work for me

/mnt/c/cosmopolitan1  ¬ printf %s '
>   main() {
>     printf("hello world\n");
>   }
> ' >hello.c
/mnt/c/cosmopolitan1  ¬ gcc -g -Os -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc \
>   -fno-omit-frame-pointer -pg -mnop-mcount \
>   -o hello.com.dbg hello.c -Wl,--gc-sections -fuse-ld=bfd \
>   -Wl,-T,ape.lds -include cosmopolitan.h crt.o ape.o cosmopolitan.a
/usr/bin/ld.bfd: warning: .note.gnu.build-id section discarded, --build-id ignored
/mnt/c/cosmopolitan1  ¬ objcopy -S -O binary hello.com.dbg hello.com
/mnt/c/cosmopolitan1  ¬ ls
ape-no-modify-self.o  ape.lds  ape.o  cosmopolitan.a  cosmopolitan.h  crt.o  hello.c  hello.com  hello.com.dbg
/mnt/c/cosmopolitan1  ¬ sh hello.com
hello.com: 8: cannot create : Directory nonexistent
/mnt/c/cosmopolitan1  ¬ ./hello.com
/mnt/c/cosmopolitan1  ¬ ./hello.com
/mnt/c/cosmopolitan1  ¬ sh hello.com
hello.com: 27: Syntax error: "(" unexpected
/mnt/c/cosmopolitan1  ¬ readelf -h hello.com
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 09 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - FreeBSD
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x40210b
  Start of program headers:          2840 (bytes into file)
  Start of section headers:          0 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         4
  Size of section headers:           0 (bytes)
  Number of section headers:         0
  Section header string table index: 0
/mnt/c/cosmopolitan1  ¬

R Z

unread,
Jan 13, 2022, 5:57:59 AM1/13/22
to cosmopolitan cosmonauts
seems that I screwed something up in the process of upgrading to wsl2. the ubuntu image I was running was still on wsl1. Once I fixed that everything began to work as expected.
Reply all
Reply to author
Forward
0 new messages