0

I used to build a project on windows and now that I am trying to build it on macos (M1) I get errors on a dependency (nested in a dependency):

pixman-0.34.0/pixman/pixman-x86.c:103:4: error: unknown register name '%eax' in asm
        : "%eax", "%ecx");
          ^
pixman-0.34.0/pixman/pixman-x86.c:136:4: error: invalid output constraint '=a' in asm
        : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d)
          ^

I also get warnings all around:

pixman-0.34.0/pixman/pixman-x86.c:83:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if _PIXMAN_X86_64 || defined (_MSC_VER) || defined(__native_client__)
    ^
pixman-0.34.0/pixman/pixman-x86.c:78:6: note: expanded from macro '_PIXMAN_X86_64'
    (defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
     ^

The project is configured with CMake with very few parameters, most of the configuration is made in the CMake of the dependency (Orthanc Stone).
There is an emscripten build of almost the same sources and libs that is working fine so I guess I'm missing something in the CMake configuration to make it work on macos.
I suppose the target architecture is not compatible with the pixman lib (and probably others that the compilation has not reached yet). But I did not find how to fix it.

I installed gcc using homebrew

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc-11
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/11.3.0/bin/../libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper
Target: aarch64-apple-darwin21
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/11 --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 11.3.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --build=aarch64-apple-darwin21 --with-system-zlib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Homebrew GCC 11.3.0)
ymoreau
  • 3,402
  • 1
  • 22
  • 60
  • That's x86 assembly (`eax` is an x86 register), but your compiler is targeting ARM (`aarch64-apple-darwin21`). – Alex Reinking Jun 23 '22 at 15:50
  • @AlexReinking does it mean the lib code cannot be built on my ARM system without setting up cross-compilation somehow? – ymoreau Jun 23 '22 at 16:24
  • 1
    Correct. You will need to cross compile. – Alex Reinking Jun 23 '22 at 16:29
  • If the end result should run on your M1 mac, cross compiling won't help. You will need to rewrite the inline assembly lines using Arm assembly (or, even better, plain C). – Lindydancer Jun 23 '22 at 20:27
  • 1
    I just notices that the file name is "pixman-x86.c". Maybe you should not built that file at all, check if there is a "pixman-arm.c" or similar. – Lindydancer Jun 23 '22 at 20:28

1 Answers1

1

The project is configured with CMake with very few parameters, most of the configuration is made in the CMake of the dependency (Orthanc).

Is it this Orthanc? How exactly are they building pixman with CMake? Pixman has lots of special cases implemented in Assembler. At build time, autoconf detects the right one to enable. Since you are writing that you are using CMake, I bet someone side-stepped all that auto-detection and just hardcoded what to build. And hardcoded the x86 build.

If this guess is right, then that is a bug in that CMake file and there is nothing anyone but orthanc devs can do about that.

Which part of orthanc are you trying to build exactly and how? I fail to find its use of cairo...

Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39
  • Thx, sorry for the late answer. I am using their client project, but it's based on the server sources too: [Orthanc-Stone](https://hg.orthanc-server.com/orthanc-stone/file/tip). I suppose the answer is in their CMake files indeed, and the way I include and configure them, I'll get back with a solution or more info when I found something – ymoreau Aug 30 '22 at 15:05
  • 1
    In the end I had to use `-DCMAKE_OSX_ARCHITECTURES=x86_64` to make it work, their build config (and some dependencies they are forcing) does not seem to be compatible with arm. – ymoreau Oct 13 '22 at 13:56