Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS "building for macOS-x86_64 but attempting to link with file built for unknown-arm64" #223

Open
rajrana22 opened this issue Aug 11, 2022 · 7 comments

Comments

@rajrana22
Copy link

rajrana22 commented Aug 11, 2022

I was recently working on an erasure coding project that was based on this ISA-L library. Everything was going fine, and I was just debugging for a while and then I left the project for about one day. Then the next day when I got back to it I ran into the error listed below. I hadn't made any changes to the code or to my Mac that I know of between the time I was off.

So I tried to start simple so I cloned the original ISA-L library again and tried to build again. Then, when I ran make I got the same errors again.

I'm running on macOS Monterey 12.5 with the M1 Apple chip.

Here is the full display of the error message:

/Library/Developer/CommandLineTools/usr/bin/make --no-print-directory all-am
  CCLD     libisal.la
ld: warning: -undefined dynamic_lookup is incompatible with dyld share cache
ld: warning: ignoring file raid/.libs/raid_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file erasure_code/.libs/ec_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file crc/.libs/crc_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/hufftables_c.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file crc/.libs/crc64_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/igzip.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/adler32_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/encode_df.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/igzip_icf_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/flatten_ll.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/igzip_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/igzip_icf_body.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/huff_codes.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file mem/.libs/mem_zero_detect_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file igzip/.libs/igzip_inflate.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: -undefined dynamic_lookup cannot be used to find '_ec_encode_data_base' in dylib in dyld shared cache for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libisal.la] Error 1
make: *** [all] Error 2

I have tried multiple solutions online, but none of them seem to work. Does anybody know how to fix this issue?

@gbtucker
Copy link
Contributor

Hi @rajrana22,

It sounds like you built objects to one target arch (x86_64) and are trying to force link the library to another (arm64). I would suggest you do all testing with a single target first. Perhaps you did some override to force a cross macOS-x86_64 CFLAGS to the compiler but the corresponding args didn't get passed to the linker.

@rajrana22
Copy link
Author

rajrana22 commented Aug 12, 2022

Thanks for the quick reply, @gbtucker. Unfortunately, I'm not very well-versed in compilers/architectures. Luckily, for the time being, I am working on a separate server that runs CentOS, and I am able to get my work done there for now. While there is no rush, I would still like to get back to working on my own MacBook. Do you know how/where I can check for something that might have messed with the compiler?

@gbtucker
Copy link
Contributor

Could you report the steps you took to setup and build? On an x86_64 mac it used to be pretty simple. You can even use brew now to install isa-l on mac but the formula is only x86_64 for now.

@rajrana22
Copy link
Author

I already had nasm installed, so I just used Autotools to build and install as mentioned in the README:

./autogen.sh
./configure
make
sudo make install

@rhpvorderman
Copy link
Contributor

I'm running on macOS Monterey 12.5 with the M1 Apple chip

So you are building for x86_64 on the M1 chip, which is arm64. The errors suggest that it tries to build for x86_64 but instead finds all these files that are compiled for arm64. The compiler selects the native arm64 architecture by default (which is reasonable). So I guess you could cross-compile to x86_64 by setting the correct compile flags?

I hadn't made any changes to the code or to my Mac that I know of between the time I was off.

That makes it very confusing. The Apple M1 chip shouldn't be able to succesfully compile ISA-L (the PR #164 is not merged yet), unless it is cross-compiling for x86_64. I have no clue why it would be able to compile before.

@rajrana22
Copy link
Author

@rhpvorderman Thank you so much! Your reply got me thinking and I found a solution. The issue was indeed what you were talking about, and I noticed that while in my regular terminal the output of arch was arm64 (which is what I should want), the output of arch in the VScode terminal was i386.

The solution was to run the following command: env /usr/bin/arch -arm64 /bin/zsh --login.

However, I'm still having issues.

When I run make I get the following error:

/Library/Developer/CommandLineTools/usr/bin/make --no-print-directory all-am
  CC       erasure_code/aarch64/ec_aarch64_dispatcher.lo
In file included from erasure_code/aarch64/ec_aarch64_dispatcher.c:29:
./include/aarch64_multibinary.h:34:10: fatal error: 'asm/hwcap.h' file not found
#include <asm/hwcap.h>
         ^~~~~~~~~~~~~
1 error generated.
make[1]: *** [erasure_code/aarch64/ec_aarch64_dispatcher.lo] Error 1
make: *** [all] Error 2

This error seems identical to one referenced in issue 86, but I'm not sure if a solution was mentioned.

@rhpvorderman
Copy link
Contributor

Disclaimer: I am not affiliated with this project, I am just a user like you. Due to my work on python-isal I have experience compiling ISA-L on multiple platforms, but M1 macs are not one of them. I do not own the hardware so I cannot test on it. Take a look at #164. You might be able to get that branch working. If not, I am sure the contributors of that branch would appreciate the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants