EMU-driver icon indicating copy to clipboard operation
EMU-driver copied to clipboard

ARM M1 issue Incompatible architecture: Cannot find arm64e in fat binary

Open bezromval opened this issue 4 years ago • 91 comments

The installer report is:

Error Domain=KMErrorDomain Code=3 "Error occurred unloading extensions: Missing extension with identifier com.emu.driver.EMUUSBAudio : Incompatible architecture: Cannot find arm64e in fat binary
Incompatible architecture: Binary is for x86_64, but needed arch arm64e" UserInfo={NSLocalizedDescription=Error occurred unloading extensions: Missing extension with identifier com.emu.driver.EMUUSBAudio : Incompatible architecture: Cannot find arm64e in fat binary
Incompatible architecture: Binary is for x86_64, but needed arch arm64e}
Error Domain=KMErrorDomain Code=71 "Incompatible architecture: Binary is for x86_64, but needed arch arm64e" UserInfo={NSLocalizedDescription=Incompatible architecture: Binary is for x86_64, but needed arch arm64e}
Waiting for the system to finish installation. Can take several minutes.
Executing: /usr/bin/kmutil install --volume-root / --check-rebuild
Rebuilding the kernel
Driver is installed and ready for use!
You can close this window.
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

bezromval avatar Feb 22 '21 17:02 bezromval

@bezromval thanks for reporting. Yes I was expecting it.

Your report "end of era ..." introduction is not so to the point and a bit negative so I removed that.

I already tried to recompile the code but it does not seem to generate the ARM binary and spits errors where the code wes compiling in the previous XCode And I don't have access to any ARM machine so even if it would compile I would be unable to test this

In short it may take some time before I can fix this

Wouter1 avatar Feb 22 '21 17:02 Wouter1

------- notes for myself

Main error message I get from the compiler:

TARGET_OS_OSX not defined
cdefs.h
In file included from ...EMUUSUAudio_info.c

Actually I'm i porting xmach/mach_types.h there. Strange, error comes not from my code but from a standard library.

Wouter1 avatar Feb 22 '21 18:02 Wouter1

XCode says the file that causes the error is EMUUSBAudio_info.c Ny project does not have such a file? It does have a file EMUUSBAudio-info.plist. Is this something odd being generated wrong?

I also can NOT edit this 'file'. The filename is also in italics, not clear what's going on

The error says something like "in file included from /Users/wouter/Library/Developer/Xcode/DerivedData/EMUUSBAudio-fjaszixeghwepcdugnckcrbgnuhj/Build/Intermediates.noindex/EMUISBAudio.build/Debug/........

That's not where I put my source files either

Wouter1 avatar Feb 22 '21 18:02 Wouter1

Similar error to here https://github.com/catchorg/Catch2/issues/2139 But no solution reported there

Wouter1 avatar Feb 22 '21 19:02 Wouter1

https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets

gives more details but it's quite confusing

Wouter1 avatar Feb 22 '21 19:02 Wouter1

INFOPLIST_PREPROCESS=YES is in the project settings (project.pbxproj). I think this creates the above mentioned file that includes cdef.h

If I uncheck that, the error remains because cdefs.h is still imported through

EMU-driver/USH.h -> IOKit/usb/StandardUSB.h -> IOKit->IOTypes.h -> IOKit/system.h -> sys/cdefs.h

Wouter1 avatar Feb 22 '21 21:02 Wouter1

If I put

#include <TargetConditionals.h>

right before the #include<IOKit/usb/StandardUSB.h>

then I get

IOKit/usb/IOUSBLog.h file not found.

Maybe this is a step in the right direction

Wouter1 avatar Feb 22 '21 21:02 Wouter1

After just removing that import, I'm back to the TERGET_OS_OSX not defined

But now through the import chain

EMUUSBAudio_info.c -> mach/mach_types.h->stdint.h -> machine/types.h -> i396/types.h -> sys/cdefs.h

Wouter1 avatar Feb 22 '21 21:02 Wouter1

Again that is NOT my file. I have turned off the preprocess info.plist file. Also the "Create Info.plist section in binary" is off.

Wouter1 avatar Feb 22 '21 21:02 Wouter1

This Derived Data seems wrong. Maybe I can find more about derivedData

https://vojtastavik.com/2018/09/02/what-is-inside-derived-data-xcode/

might help

Wouter1 avatar Feb 22 '21 21:02 Wouter1

Is this an XCode configuration issue?

https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html

Wouter1 avatar Mar 14 '21 13:03 Wouter1

Well that first line there is already confusing. " you install Xcode, the installer creates a /Developer/SDKs directory"

I HAVE Xcode installed. But I don't have /Developer.

EDIT: but XCode works fine, i now compiled the driver. That first line must be incorrect.

Wouter1 avatar Mar 14 '21 13:03 Wouter1

The error disappears if I set in project the Apple Clang-Preprocessing / Preprocessor macros add TARGET_OS_OSX=1

EDIT: This seems indeed needed. When I remove it the build fails.

But then a new error appears in EMUUSBAudioDevice.h line 249 Invalid operands to binary expression ('nullptr_t' and 'UInt8')

Wouter1 avatar Mar 14 '21 14:03 Wouter1

If I change that line the NULL to 0 I get another error

IOKit/usb/IOUSBLog.h' file not found

Wouter1 avatar Mar 14 '21 14:03 Wouter1

https://developer.apple.com/forums/thread/72248 These files do not exist apparently above 10.10

Wouter1 avatar Mar 14 '21 14:03 Wouter1

If I comment out that line, I get another error, EMUUSBAudioDevice.cpp ine 335

because audioEngine.init(NULL) apparently returns boolean. I was comparing it with NULL==. Changed to !audioEngine.init(NULL).

After that, build succeeds! But not clear yet what that means, do we now have fat binary and how to test it

Wouter1 avatar Mar 14 '21 14:03 Wouter1

In that building project, I now have "macOS Deployment Target" set to MacOS 10.12" and Base SDK macOS. But it also works if I set the deployment target to macOS 11.0.

Project format is XCode 3.2-compatible.

Wouter1 avatar Mar 14 '21 14:03 Wouter1

I didn't understand any word you write up here, but I'm waiting here for some beta driver for M1 and would like to test it on my MacBook Air with m1 chip and I already have proper usb type c printer cable for it. Just let me know here.

bezromval avatar Mar 14 '21 14:03 bezromval

@bezromval thanks for offering help on testing. I have no ARM machine so I can not test anything.

I have at this point something compiling on xcode 12.5 beta. FAIK this should support ARM compilation.

But It's not clear what the compiled driver is at this point. But given that it's 458kB size, strongly suggests it's not fat but just 1 architecture. That probably is intel as I could nowhere select any ARM compilation target...

The notes above are tech notes for myself, documenting what I do. I have not much time so occasionally I have a few hours. It's then essential that I can continue on, rather than redo, what I did last time. Hence all these notes.

Wouter1 avatar Mar 14 '21 15:03 Wouter1

Maybe here https://www.lewuathe.com/how-to-make-arm-cross-compilation-on-macos.html or https://www.starmessagesoftware.com/blog/compile-macos-desktop-application-arm64-apple-silicon-m1-chip-cpu

Wouter1 avatar Mar 14 '21 15:03 Wouter1

Yes, lipo -info .....kext/Contents/MacOS/EMUUSBAudio gives only x86_64 so not good yet.

Wouter1 avatar Mar 14 '21 15:03 Wouter1

The required flags are in the project, under build settings/architecture.

The Architectures are set to Standard Arcitectures (Apple Silicon, Intel) so that looks good.

If I set "Build Active Architectures Only" to "Yes" it builds fine. I had that setting for the Debug mode; and aparently Build builds the debug version...

But if I set it to No then I get another error

EMUUSBAudioEngine line 47 Allocating an object of abstract class type 'EMUUSBAudioEngine (?? looks like a conclusion, not an error message)

Wouter1 avatar Mar 14 '21 15:03 Wouter1

Maybe the class EMUUSBAudioEngine does not implement one of the many virtual functios of the superclass?

I see differences, for instance performFormatChange/4 while it was /3 getStatusDescriptor/1 I don't see it in imple getNearestStartTime I don't see it in imple

How does this work, why does it compile for debug but not for run?

Wouter1 avatar Mar 14 '21 16:03 Wouter1

Maybe it compiles ok on intel but not on arm? If you switch the "build active architecture only' to 'yes' for debug mode, and if build by default only copmpiles the debug version?

Does that imply that the superclass IOAudioEngine differs between ARM and Intel?

Wouter1 avatar Mar 14 '21 16:03 Wouter1

Even weirder, the error ALSO shows in intel. However in spite of the error, the build succeeds there anyway.

In the older compiler, there was no error at all at this place.

If you look at the virtual function performFormatChange, it was always performFormatChange/4. Yet my implementation is performFormatChange/3. How can a function call with an incorrect number of args be accepted at all? The code does not say it was overriding though. What is going on here? Was the function never assumed to override/implement the virtual function? Was it never called?

Wouter1 avatar Mar 14 '21 20:03 Wouter1

There is more detail on the error message in the issue navigator on the left. Unfortunately it's very hard to find that detail as there is a huge list of warnings, it's completely hidden between those.

it says

unimplemented virtual method driverDesiredHiResSampleIntervals in EMUUSBAudioEngine

Wouter1 avatar Mar 14 '21 21:03 Wouter1

The doc actually says "this is a new method which only exists on ARM platforms and therefore breaks binary compatibility if this is compiled on intel platforms"..... Well at least they have documented this.

Wouter1 avatar Mar 14 '21 21:03 Wouter1

Added the missing function, only for ARM. It now compiles. Created new M1 branch and pushed the new code there, including the new kext version v15

Wouter1 avatar Mar 14 '21 21:03 Wouter1

@bezromval I just created a first version of the M1 driver. I have no idea what it will do, so please be careful. Maybe run from a separate partition just in case.

There is a new M1 branch containing a new version of the driver : v15

https://github.com/Wouter1/EMU-driver/tree/M1

It's in the v15 directory.

The installation script is NOT recognising that new file yet.

Can you install the v15 driver manually in /Library/Extensions and see what it does?

Wouter1 avatar Mar 14 '21 21:03 Wouter1

Thanks for spending your free time for this! I’ve just tried to install driver. What I've done: 1 boot in recovery mode, lunch terminal and use command csrutil disable. It disabled successfully. Reboot Mac. 2 copy new EMUUSBAudio.kext from v15 to the /Library/Extensions 3 In the system preferences/security and privacy allow this action and system cache was rebuild automatically. 4 Reboot system 5 Sound card did not appeared in system preferences/sound.

bezromval avatar Mar 15 '21 15:03 bezromval