You need to log in to create posts and topics.

Apple Silicon M1 build - it's working!

Hi guys, here is "what I did" to get a native SimulIDE.arm64 build under macOS.
Build system:
Macbook M1, macOS Sequoia v15.0
XCode 16.0 (16A5171c) with command line tools (xcode-select --install)
Qt 5.15.13 arm64 (brew install qt@5)
Changes to SimulIDE-dev (current HEAD revision):
1. Get AngelScript SDK 2.37.0 from http://www.angelcode.com . Delete all in /src/angel/ folder and unpack include and src SDK folders there.
2. Update /SimulIDE.pri :
add SOURCES += $$files( $$PWD/src/angel/src/*.S, true ) after row 15
change under macx {
QMAKE_CC = gcc
QMAKE_CXX = g++
QMAKE_LINK = g++
Actually, this is not a real gcc, but clang wrapper. Gnu gcc installed with brew would not work well.
3. Disable clang to pick file src/angel/src/as_callfunc_arm64_gcc.S , do it with 
#ifndef __clang__ at start and #endif at end of that file. Thus it will compile as_callfunc_arm64_xcode.S which is what we need.
4. To get new angelscript working, replace getGlobalVarData() in src/microsim/cores/scripted/scriptcpu.cpp:227 with this:

const char* name;
const char* nameSpace;
const char* type;
int typeId;
const asITypeInfo* typeInfo;
bool isConst;
if( module->GetGlobalVar( i, &name, &nameSpace, &typeId, &isConst ) != asINVALID_ARG ){
  if(typeInfo=module->GetTypedefByIndex(typeId)){
    type = typeInfo->GetName();
    QStringList list = m_typeWords.value( QString( type ) );
    m_memberWords.insert( QString( name ), list );
  }
}

The last step is to disable JIT from Blind Mind Studios - it don't have arm64 support.
- add something like this
#ifdef __APPLE__
#define SIMULIDE_W32
#endif
at the beginning of src/microsim/modules/script/scriptbase.h . This will disable JIT in many places. New angelscript handles native code under the hood, so I didn't notice any valuable performance impact for scripted components.

That's all, folks. Go to build_XX folder and run qmake && make -j 8
Ping me if it worth a PR.
Cheers !

Hi, That's great.

Compiling for ARM is something I still need to fix.
This definetly will help.

But we need to do it with the modified version of AngelScript.
The difference in performance is not noticeable in scripts that run at low frequencies.
In these cases the speed of execution doesn't matter too much: a difference between 0.1% and 1% cpu usage is not noticeable even when it is a 10x. But the difference between 50% and 500% cpu usage changes everything.

I did some changes to try to fix compilation for ARM at commit 4205aa4

Feel free to try it and see if it works or there are some other changes needed.

Still need some fixes
 
/bin/sh: /usr/local/Cellar/gcc@7/7.5.0_4/bin/g++-7: No such file or directory - at SimulIDE.pri
Correct is just g++ . GNU gcc is not working good for aarch64, you must use XCode clang.
Anyway, using absolute paths for win/lin/mac cross-platform app is not smart. Trust your $PATH 🙂
 
src/microsim/modules/script/scriptbase.h:48:9 error: unknown type name 'asCJITCompiler'
Don't call it directly, new angelscript have its own embedded JIT. 
#ifdef __x86_64__ for #include "as_jit.h" is probably good, but not enough, you must also skip all JIT types and calls in .cpp 
 
About performance. As I said, new angelscript have it's own JIT embedded, and I suppose it can be faster than 3rd solutions.
I tested some sim1 from examples, and didn't noticed any valuable cpu load, for example /Micro/Peripherals/DS1307_uno takes 4% cpu, which is very close to idle. If you have really complex schematic to test - let me know.
 
Well. A journey of a thousand miles begins with a single step. 
 
BTW, I'm very interested in the revival of Arduino compiler - data/codeeditor/compilers/compilers/arduino.xml is not working out-of-box, I'm writing a new one both for Arduino IDE and arduino-cli packages, and src/gui/editorwidget/debuggers/inodebugger.cpp , which is also needs some updates. Probably it's OsX issues only.
 
Cheers!
 
 
/bin/sh: /usr/local/Cellar/gcc@7/7.5.0_4/bin/g++-7: No such file or directory - at SimulIDE.pri
Correct is just g++ . GNU gcc is not working good for aarch64, you must use XCode clang.
Anyway, using absolute paths for win/lin/mac cross-platform app is not smart. Trust your $PATH 🙂
I would "trust" my $PATH if I could, but QTCreator in MacOs wants to force me to use clang even if I tell it to use gcc.
In order to use gcc I need to "force" it by using absolute  paths.
You need to edit those values for your needs.
Not 100% sure what is smart and what is not... 😉
 
Don't call it directly, new angelscript have its own embedded JIT.
As far as I know Agel Script has a JIT interface, not a JIT compiler.
And it is not "called" from simulide, but a pointer to the JIT compiler is needed to delete it in dtor.
 
About performance. As I said, new angelscript have it's own JIT embedded, and I suppose it can be faster than 3rd solutions.
I tested some sim1 from examples, and didn't noticed any valuable cpu load, for example /Micro/Peripherals/DS1307_uno takes 4% cpu, which is very close to idle. If you have really complex schematic to test - let me know.
The differences in performance can be much more than 10x depending on the case.
 
/Micro/Peripherals/DS1307_uno has nothing to do with scripts.
In any case to do some test you should compare modified version of AngelScript in simulide (with JIT compiler) against original version (that lacks a JIT compiler for ARM), which does not seem possible.
 
BTW, I'm very interested in the revival of Arduino compiler - data/codeeditor/compilers/compilers/arduino.xml is not working out-of-box, I'm writing a new one both for Arduino IDE and arduino-cli packages, and src/gui/editorwidget/debuggers/inodebugger.cpp , which is also needs some updates. Probably it's OsX issues only.
If you have some problems with the Arduino compiler in MacOs maybe you can report.
I think it worked for some other people, but I haven't tested it.
In Linux and Windows it is working for me.
 

Hi guys,
Today we will fix Arduino sketch "Compile" button, which is not working in MacOS. (Win & Lin are ok).
It took a bit of time to understand tricky thing: there are two different ways to build under OsX, and both are not working out-of-box 🙂 First one using arduino-cli (brew install arduino-cli) and second calling Arduino IDE toolchain directly (/data/codeeditor/compilers/compiler/arduino.xml) - Tricky but powerful. So... Easy First.
1. Init CLI settings: arduino-cli config init - this will create ~/Library/Arduino15/arduino-cli.yaml where some things supposed to be defined.
2. Add your IDE Library path: arduino-cli config set directories.data ~/Library/Arduino15
3. Modify src/gui/editorwidget/debuggers/inodebugger.cpp:188
#ifndef __APPLE__
   builder = findFile( path+"resources/app/", builder );
#else
   builder = findFile( path + "/" , builder );
#endif
4. Open your .ino sketch and press Gear icon at left, then choose File Settings -> Compiler -> Arduino
5. Under same gear choose Compiler Settings.
Set Tool Path to /opt/homebrew/bin/ (M1) or /usr/local/bin/ (x86), run whereis arduino-cli if not sure.
Set Custom Library Path to ~/Library/Arduino15/libraries/
Set Board: Uno (your sketch board)
Set Include Path to ~/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/
Set Device to atmega328p and close settings. They will be stored in Library/Application Support/simulide/simulide.ini and your project.

That's all, folks. Click "Compile" and "Upload" buttons. 
P.S. If you encounter errors with ~ symbol - replace it with your home dir path.
Happy simming !

Thanks for the tips.

What works for me:
1- Download Arduibo IDE.app and add to /Applications.
2- Open Arduino sketch and in Settings->Compiler settings set Tool Path to: /Applications/Arduino IDE.app/Contents/
https://simulide.com/p/forum/topic/tool-path-for-macos-14-5-simulide-1-1-0-and-arduino-2-3-2/

That's all.

Yep, a bit easier.
But. arduino-cli shipped with IDE have version 0.35.3 and current is 1.0.4 - they fixed plenty of bugs I saw on github.
And if I use HEAD revision of SimulIDE (at least aarch64), I feel some sense to use latest tools.
Also, Arduino IDE itself don't use embedded arduino-cli for building, but prefer to call avr-gcc. It is quite suspicious... 😉