unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.67k stars 1.35k forks source link

Fails to build on MacOS Sonoma #1993

Closed theoparis closed 3 months ago

theoparis commented 3 months ago
.h:30:
  /Users/theo/.cargo/git/checkouts/unicorn-833fdf2c7ca85395/d4b9248/qemu/include/qemu/int128.h:150:16: error: typedef redefinition with different types ('Int128' (aka 'struct Int128') vs '__int128')
  typedef Int128 __int128_t;
                 ^

After commenting this line out, I get these errors:

  /Users/theo/Documents/src/macos-arm64-emulation/unicorn/qemu/util/osdep.c:66:9: error: call to undeclared function 'mprotect'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      if (mprotect(addr, size, prot)) {
          ^
  /Users/theo/Documents/src/macos-arm64-emulation/unicorn/qemu/util/osdep.c:79:45: error: use of undeclared identifier 'PROT_READ'
      return qemu_mprotect__osdep(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC);

and

 /Users/theo/Documents/src/macos-arm64-emulation/unicorn/qemu/include/qemu/osdep.h:32:10: fatal error: 'config-target.h' file not found
  #include "config-target.h"
           ^~~~~~~~~~~~~~~~~

Not sure what's going on...

theoparis commented 3 months ago

Nevermind, it turns out my custom built clang doesn't pick up Xcode headers and libraries. I added

export LDFLAGS="-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib"
export CFLAGS="-isystem/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
export CXXFLAGS="-isystem/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"

to my .zshrc and it fixed the problem.