omnetpp / omnetpp

OMNeT++ Discrete Event Simulator
https://omnetpp.org
599 stars 151 forks source link

Support for Apple Silicon #912

Closed rhornig closed 1 year ago

rhornig commented 2 years ago

Support mac OS on AARCH64 architecture. This is a general issue tracking all problems, milestones until we can officially distribute an Aarch64 version for macOS. Right now, we can generate a distro for macos-aarch64, with bundled JRE and IDE for aarch64.

What is missing:

dragos-bth commented 2 years ago

First attempt at installing omnetpp-6.0rc1-macos-aarch64 under macOS Monterey with MacPorts did not go well.

All Python dependencies were installed using port install except for posix_ipc, which does not have a corresponding port. That one I installed using pip (ends up in ~/Library/Python/3.10/lib/python/site-packages). Python3 can find it, which I verified by running python3 from the command line and then executing succesufully import posix_ipc;. However, as soon as I execute source setenv in the omnetpp directory something happens with the search path for python modules and the configure script fails to find posix_ipc. Interestingly, if I run pip at this point I can see posix_ipc installed under tools/macos.aarch64/lib/Python.framework/Versions/Current/lib/python3.10/site-packages , but the configure script still does not find it.

I edited the configure script and commented out the test for posix_ipc, but then I hit the next road block: qt5. Currently, this seems to be broken under MacPorts as it fails when patching. Not sure if I want to spend time fixing the qt5 build, so my next attempt will be to try satisfy the omnetpp dependencies using brew.

dragos-bth commented 2 years ago

Using brew actually went worse than MacPorts... I installed most dependencies manually, but ./configure is not happy about bison

checking for bison... bison -y configure: error: At least bison version 3.0 required -- type 'bison -y --version' to see the version number

Next attempt will be to try building the Linux ARM version in a VM....

rhornig commented 2 years ago

Thanks for testing. Indeed the AARCH port specifically assumes that the toolchain is installed in tools/macos.aarch64. To work properly with the globally installed homebrew or macports lib, the configure file must be fixed. I'm not sure which is the more work, creating an aarch toolchain, or fixing the configure script. I will take a look at the problem after the 6.0 release, so proper AARCH support will have to wait for OMNeT++ 6.1

dragos-bth commented 2 years ago

qt-5 was fixed today in the MacPorts repo so I gave it another shot.

First, I commented out posix_ipc from the configure script. Then I turned off OSG and OSG_EARTH (=no) in configure.user since the configure script could not find the OSG installation. Also, I had to create a symlink to qmake becasue the configure script could not find it:

sudo ln -s /opt/local/libexec/qt5/bin/qmake /opt/local/bin/qmake

After all these steps, configure completed succesfully. Unfortunately, make died rather early in the build process:

dil@mac4-wifi omnetpp-6.0rc1 % make

Building release and debug mode executables. Type 'make help' for further options.

***** Configuration: MODE=release, TOOLCHAIN_NAME=clang, SHARED_LIBS=yes, LIB_SUFFIX=.dylib ****
===== Checking environment =====
===== Compiling utils ====
===== Compiling common ====
make[2]: *** No rule to make target `/Users/dil/tmp/omnetpp-6.0rc1/out/clang-release/src/common/lcgrandom.o', needed by `/Users/dil/tmp/omnetpp-6.0rc1/out/clang-release/src/common/liboppcommon.dylib'.  Stop.
make[1]: *** [common] Error 2
make: *** [allmodes] Error 2

If you can point me to some instructions on how to build the toolchain (at least for an existing architecture), I could give a shot to AARCH64 on my own.

I have pre15 installed in a VM, so I can do my regular work, but I will also try the x86_64 (rosetta)

dragos-bth commented 2 years ago

macos-x86_64 installed flawlessly with dependencies installed through MacPorts. I did not have to do any changes to the configure scripts. All dependencies (qt-5, posix_ipc, OSG, OGS_EARTH) were discovered automatically. Currently, I have the devel version of OSG installed under MacPorts (not sure if it is mandatory, but non-devel and devel cannot co-exist at the moment).

I was able to run the aloha simulation with no problem. The only negative artifact shows up when I start omnetpp. The Eclipse(OMNeT++ logo is so tiny you can't see the text side (4K screen). However, the Eclipse GUI scales the fonts as expected in all windows so it's definitely no problem.

I will switch from the Linux ARM VM (pre15) to this installation (6.0rc1) for my day to day work. If I find any issues, I will report them here first.

rhornig commented 2 years ago

Regrettably, I had to postpone native macOS aarch64 version to a later release. Until then, the x86 version should work fine under rosetta2. All dependencies (except the compiler and build tools) are bundled, however bundling everything is quite unconvenient. I will look into the possibility not bundling the dependencies but instead using macPorts, homebrew on even better NIX as an external package manager.

rhornig commented 2 years ago

@dragos-bth A bit of progress: In recent weeks I was working on creating a NIX installation package for OMNeT++. I'm happy to say than it is now working both on Linux/macOS and (x86_64/aarch64). Currently it does NOT include the IDE, but you can build and deploy OMNeT++ based simulations from the command line.

  1. Go to https://nixos.org and install the NIX package manager.
  2. In your editor open ~/.config/nix/nix.conf and add the following: experimental-features = nix-command flakes Or simply execute: echo "experimental-features = nix-command flakes" >>~/.config/nix/nix.cfg
  3. Restart your shell and check if NIX works correctly (e.g. nix flake --help)
  4. Get a development shell with OMNeT++ 6.0.1 installed: nix develop -i github:omnetpp/omnetpp/flake/omnetpp-6.0.x
  5. Go to your model directory and use opp_makemake, make etc. Qtenv should work just fine in the shell.
dragos-bth commented 1 year ago

@rhornig Thanks for the update! I am looking forward to try out the build. It will probably happen towards the end of next week as other things at work were forced up the prio list...

dragos-bth commented 1 year ago

@rhornig Thanks for the update! I am looking forward to try out the build. It will probably happen towards the end of next week as other things at work were forced up the prio list...

dragos-bth commented 1 year ago

@rhornig : before installing nixos, I would like to know if and how it interferes with macports, brew and fink. I am currently om macports and it will be a problem for me if nixos interferes with it (in the sense of conflicts). If that is the case, I would rather run the Rosetta 2 builds for omnetpp on MacOS.

rhornig commented 1 year ago

sorry for the long delay. to clarify: nixos is a linux distro using NIX as a package manager. So we are speaking just about installing the NIX package manager.

So, installing nix provides ONLY the nix package manager in your system path, nothing else, so it should not interfere with anything in the system. Any nix based packages should be explicitly installed by nix-env, but building omnet with nix packages does NOT require any changes in your system. You can invoke a nix shell which contains all the necessary packages, but no changes are made to any global state so once you exit that shell, nothing remains.

Long story short, it should not interfere with anything on your system (and vica versa, the nix shells are clean environment, so by default nothing is accessible there except what you specifically request), so already installed software will not interfere either.

MoienBowen commented 1 year ago

Using brew actually went worse than MacPorts... I installed most dependencies manually, but ./configure is not happy about bison

checking for bison... bison -y configure: error: At least bison version 3.0 required -- type 'bison -y --version' to see the version number

Next attempt will be to try building the Linux ARM version in a VM....

I know this is a old post, but here is the solution I found, hope it can help others. Source: https://stackoverflow.com/questions/10778905/why-does-my-mac-os-x-10-7-3-have-an-old-version-2-3-of-gnu-bison

arganzhengs-MacBook-Pro:thrift argan$ brew unlink bison
Unlinking /usr/local/Cellar/bison/3.0.4... 0 symlinks removed
arganzhengs-MacBook-Pro:thrift argan$ brew link bison
Warning: bison is keg-only and must be linked with --force
Note that doing so can interfere with building software.
arganzhengs-MacBook-Pro:thrift argan$ brew link bison --force
Linking /usr/local/Cellar/bison/3.0.4... 9 symlinks created
arganzhengs-MacBook-Pro:thrift argan$ bison -V
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
arganzhengs-MacBook-Pro:thrift argan$ source ~/.bash_profile 
arganzhengs-MacBook-Pro:thrift argan$ bison -V
bison (GNU Bison) 3.0.4
Written by Robert Corbett and Richard Stallman.

All package I installed with brew (except the those do not exist in brew).

dragos-bth commented 1 year ago

@rhornig Trying to follow the instructions to install nixos, but it seems the nix.cfg is missing or located somewhere else. Any ideas of alternative locations for nix.cfg or should I just create one containing experimental-features = nix-command flakes ? nixos was installed with sh <(curl -L https://nixos.org/nix/install)

dil@mac~ % echo "experimental-features = nix-command flakes" >>~/.config/nix/nix.cfg zsh: no such file or directory: /Users/dil/.config/nix/nix.cfg

rhornig commented 1 year ago

@dragos-bth yes, you should create that file first i.e. touch ~/.config/nix/nix.cfg.

As a side note we are working on something interesting: https://github.com/omnetpp/opp_env

It is currently usable only on Linux, but I'm working towards the goal to run it also on mac OS. Once that is done, you will be able to install OMNeT+ any supported version of several models by a single opp_env command.

rhornig commented 1 year ago

aaand... We got to the point where opp_env works on Linux/macOS on x86_64/aarch64 architectures. Currently supported omnet and model versions:

omnetpp    6.0.x  6.0.1  6.0.0  5.7.x  5.7.0  5.6.x  5.6.2  5.6.1  5.6.0  5.5.x  5.5.1  5.5.0  5.4.x  5.4.1  5.4.0  5.3.x  5.3.0  5.2.x  5.2.1  5.2.0  5.1.x  5.1.1  5.1.0  5.0.x  5.0.0  4.6.x  4.6.0  4.5.x  4.5.0  4.4.x  4.4.1  4.4.0  4.3.x  4.3.1  4.3.0  4.2.x  4.2.2  4.2.1  4.2.0  4.1.x  4.1.0  4.0.x  4.0.1  4.0.0  3.3.x  3.3.1  master
inet       4.5.0  4.4.1  4.4.0  4.3.9  4.3.8  4.3.7  4.2.10  4.2.9  4.2.8  4.2.7  4.2.6  4.2.5  4.2.4  4.2.3  4.2.2  4.2.1  4.2.0  4.1.2  4.1.1  4.1.0  4.0.0  3.8.3  3.8.2  3.8.1  3.8.0  3.7.1  3.7.0  3.6.8  3.6.7  3.6.6  3.6.5  3.6.4  3.6.3  3.6.2  3.6.1  3.6.0  3.5.x  3.5.0  3.4.0  3.3.0  3.2.4  3.2.3  3.2.2  3.2.1  3.2.0  3.1.x  3.1.1  3.1.0  3.0.x  3.0.0  2.6.x  2.6.0  2.5.x  2.5.0  2.4.x  2.4.0  2.3.x  2.3.0  2.2.x  2.2.0  2.1.x  2.1.0  2.0.x  2.0.0  master
veins      5.2  5.1  5.0  4.7.1  4.7  4.6  4.5  4.4  4.3  3.0  master
simulte    1.2.0  1.1.0  0.9.1
simu5g     1.2.2  1.2.1  1.1.0
inet-gpl   1.0

A lot of other older models are coming soon...

rhornig commented 1 year ago

Finally. opp_env version 0.24.0 now works on aarch64 along with the IDE. Debugging is also working with the the bundled lldbmi2 wrapper. All changes required changes are present in the 6.0.x, 6.x and master branch.