unikraft / pykraft

Python library for configuring and building unikernels
Other
177 stars 42 forks source link

macOS support #12

Open beriberikix opened 4 years ago

beriberikix commented 4 years ago

Describe the bug kraft errors when trying to use on Catalina 10.15.3. I believe this is due to changes in the default GNU libraries Apple includes.

To Reproduce Steps to reproduce the behavior:

  1. kraft init -a helloworld my_unikernel
  2. kraft configure -m x86_64 -p kvm
  3. Output:
    2020-02-27 08:25:49 INFO     Using x86_64@master
    2020-02-27 08:25:49 INFO     Using kvm@master
    2020-02-27 08:25:49 INFO     make: Entering directory '/Users/jonathanberi/.unikraft/unikraft'
    sed: illegal option -- r
    usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
    Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
    sed: 1: stdin: \1 not defined in the RE
    sed: 1: stdin: \1 not defined in the RE
    sed: 1: stdin: \1 not defined in the RE
    sed: 1: stdin: \1 not defined in the RE
    sed: 1: stdin: \1 not defined in the RE
    Makefile:450: *** Target architecture () is currently not supported (could not find /Users/jonathanberi/.unikraft/unikraft/arch///Makefile.uk)..  Stop.
    2020-02-27 08:25:49 INFO     make: Leaving directory '/Users/jonathanberi/.unikraft/unikraft'

Expected behavior An initialized unikernel.

Additional context If macOS isn't currently supported, it might be worth mentioning supported host OSes in the README.

beriberikix commented 4 years ago

I installed a few of the needed packages view brew and added them to my path per SO:

export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/flex/bin:$PATH"
export PATH="/usr/local/opt/bison/bin:$PATH"

I'm now running into a clang error when I try kraft up:

clang: error: unknown argument: '-fno-tree-sra'
clang: warning: optimization flag '-fno-reorder-blocks' is not supported [-Wignored-optimization-argument]

jonathanberi:my_unikernel 🚀 $ clang -v Apple clang version 11.0.0 (clang-1100.0.33.16) Target: x86_64-apple-darwin19.3.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

beriberikix commented 4 years ago

I tried installed gcc from brew and setup some aliases:

export CC=/usr/local/bin/gcc-9
export CXX=/usr/local/bin/g++-9
export CPP=/usr/local/bin/cpp-9
export LD=/usr/local/bin/gcc-9
alias c++=/usr/local/bin/c++-9
alias g++=/usr/local/bin/g++-9
alias gcc=/usr/local/bin/gcc-9
alias cpp=/usr/local/bin/cpp-9
alias ld=/usr/local/bin/gcc-9
alias cc=/usr/local/bin/gcc-9

However, I'm still seeing the clang error. It might be related to the gxx includes. I'm trying to parse the main Makefile, wish me luck 😂.

Here's the full output:

jonathanberi:my_unikernel 🚀 $ kraft up -p kvm -m x86_64 helloworld
2020-02-27 10:13:11 INFO     Initialized new unikraft application 'helloworld' in /Users/jonathanberi/code/my_unikernel
2020-02-27 10:13:11 INFO     Using x86_64@master
2020-02-27 10:13:11 INFO     Using kvm@master
2020-02-27 10:13:12 INFO     make: Entering directory '/Users/jonathanberi/.unikraft/unikraft'
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
2020-02-27 10:13:12 INFO     LN      Makefile
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
2020-02-27 10:13:12 INFO     mkdir -p /Users/jonathanberi/code/my_unikernel/build/kconfig/lxdialog
2020-02-27 10:13:12 INFO     make --no-print-directory CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" \
2020-02-27 10:13:12 INFO     obj=/Users/jonathanberi/code/my_unikernel/build/kconfig -C /Users/jonathanberi/.unikraft/unikraft/support/kconfig -f Makefile.br /Users/jonathanberi/code/my_unikernel/build/kconfig/conf
2020-02-27 10:13:12 INFO     /usr/bin/gcc -I. -I/Users/jonathanberi/code/my_unikernel/build/kconfig -DCONFIG_=\"\"   -c fixdep.c -o /Users/jonathanberi/code/my_unikernel/build/kconfig/fixdep.o
2020-02-27 10:13:12 INFO     /usr/bin/gcc -I. -I/Users/jonathanberi/code/my_unikernel/build/kconfig -DCONFIG_=\"\"   /Users/jonathanberi/code/my_unikernel/build/kconfig/fixdep.o -o /Users/jonathanberi/code/my_unikernel/build/kconfig/fixdep
2020-02-27 10:13:14 INFO     #
2020-02-27 10:13:14 INFO     # configuration written to /Users/jonathanberi/code/my_unikernel/.config
2020-02-27 10:13:14 INFO     #
2020-02-27 10:13:14 INFO     make: Leaving directory '/Users/jonathanberi/.unikraft/unikraft'
2020-02-27 10:13:14 INFO     make: Entering directory '/Users/jonathanberi/.unikraft/unikraft'
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
2020-02-27 10:13:15 INFO     make[1]: Nothing to be done for 'fetch'.
2020-02-27 10:13:15 INFO     make: Leaving directory '/Users/jonathanberi/.unikraft/unikraft'
2020-02-27 10:13:15 INFO     make: Entering directory '/Users/jonathanberi/.unikraft/unikraft'
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
2020-02-27 10:13:15 INFO     CP      config
2020-02-27 10:13:15 INFO     make: Leaving directory '/Users/jonathanberi/.unikraft/unikraft'
2020-02-27 10:13:15 INFO     make: Entering directory '/Users/jonathanberi/.unikraft/unikraft'
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
2020-02-27 10:13:16 INFO     CC      libkvmplat: trace.common.o
clang: error: unknown argument: '-fno-tree-sra'
clang: warning: optimization flag '-fno-reorder-blocks' is not supported [-Wignored-optimization-argument]
make[1]: *** [/Users/jonathanberi/.unikraft/unikraft/support/build/Makefile.build:46: /Users/jonathanberi/code/my_unikernel/build/libkvmplat/trace.common.o] Error 1
make: *** [Makefile:919: sub-make] Error 2
2020-02-27 10:13:16 INFO     make: Leaving directory '/Users/jonathanberi/.unikraft/unikraft'
2020-02-27 10:13:16 ERROR    Could not find unikernel: /Users/jonathanberi/code/my_unikernel/build/my_unikernel_kvm-x86_64
2020-02-27 10:13:16 INFO     Have you tried running `kraft build`?
nkcr commented 3 years ago

struggling with the same. Is there any plan to support MacOS ?

adminy commented 2 years ago

There's always docker within macos 😅 just mentioning it if you may have not considered that.

I find that this python utility is a little overengineered tbh.

skuenzer commented 2 years ago

I would love to have native MacOS support, too. Luckily we put almost all commands as variables in the main Makefile. I think we just need to detect there that we are on Mac and then populate these command variables differently. Ideally they should fit with a standard brew installation. I also noticed that MacOS's Make is too old (at least mine). Maybe, while detecting, we can call a submake process by using a newer version installed by brew...