Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Cross-compilation settings for arm-apple-darwin ("M1 Macs") #33

Merged
merged 1 commit into from
Jan 17, 2022

Conversation

reishoku
Copy link
Contributor

@reishoku reishoku commented Jan 3, 2022

This patch enables cross-compilation of vde_vmnet along with vde_switch for arm64-apple-darwin (so-called "M1 Macs") on x86_64-apple-darwin (so-called "Intel Macs").


At least on my environment, working steps to cross-compile are as follows:

  1. (optional? not clear) Install Xcode (not Xcode Command Line Tools)
  2. git clone https://github.com/virtualsquare/vde-2.git
  3. cd vde-2
  4. export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
  5. export CC=$(xcrun --sdk macosx --find clang)
  6. export CXX=$(xcrun --sdk macosx --find clang++)
  7. export CFLAGS="-arch arm64e -isysroot $SDKROOT -Wno-error=implicit-function-declaration"
  8. export CXXFLAGS=$CFLAGS
  9. ./configure --prefix=/opt/vde --host=arm-apple-darwin --target=arm-apple-darwin --build=x86_64-apple-darwin
  10. make -j3 V=1
  11. sudo make install PREFIX=/opt/vde
  12. git clone https://github.com/lima-vm/vde_vmnet
  13. cd vde_vmnet
  14. make -j3 PREFIX=/opt/vde
  15. sudo make PREFIX=/opt/vde install
  16. Done.

Logs:

reishoku@Jasmine ~/D/v/vde_vmnet (master)> uname -a
Darwin Jasmine.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
reishoku@Jasmine ~/D/v/vde_vmnet (master)> file /opt/vde/bin/*
/opt/vde/bin/dpipe:        Mach-O 64-bit executable arm64e
/opt/vde/bin/unixcmd:      Mach-O 64-bit executable arm64e
/opt/vde/bin/vde_autolink: Mach-O 64-bit executable arm64e
/opt/vde/bin/vde_over_ns:  Mach-O 64-bit executable arm64e
/opt/vde/bin/vde_pcapplug: Mach-O 64-bit executable arm64e
/opt/vde/bin/vde_plug:     Mach-O 64-bit executable arm64e
/opt/vde/bin/vde_plug2tap: Mach-O 64-bit executable arm64e
/opt/vde/bin/vde_router:   Mach-O 64-bit executable arm64e
/opt/vde/bin/vde_switch:   Mach-O 64-bit executable arm64e
/opt/vde/bin/vde_vmnet:    Mach-O 64-bit executable arm64e
/opt/vde/bin/vdecmd:       Mach-O 64-bit executable arm64e
/opt/vde/bin/vdeterm:      Mach-O 64-bit executable arm64e
/opt/vde/bin/wirefilter:   Mach-O 64-bit executable arm64e

@reishoku reishoku force-pushed the arm64-cross-compile branch from 25190d3 to 9839b8e Compare January 3, 2022 15:38
@reishoku
Copy link
Contributor Author

reishoku commented Jan 3, 2022

Maybe creating FAT binary with lipo is better? I will work on this (creating FAT binary), if needed.

@AkihiroSuda AkihiroSuda requested a review from jandubois January 3, 2022 15:49
# for x86_64
sudo make PREFIX=/opt/vde install
# for arm64
sudo make PREFIX=/opt/vde.arm64 install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to install arm64 binary.

Probably you should install the binaries in name: Make section

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment.

This should fix the issue, I assume.

Signed-off-by: KOSHIKAWA Kenichi <reishoku.misc@pm.me>
@reishoku reishoku force-pushed the arm64-cross-compile branch from 4e96c6a to 4ffc5f7 Compare January 12, 2022 15:38
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 5b03948 into lima-vm:master Jan 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants