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

Cann't build for armv7 with "neon" #16018

Closed
Dirreke opened this issue Jun 13, 2023 · 13 comments
Closed

Cann't build for armv7 with "neon" #16018

Dirreke opened this issue Jun 13, 2023 · 13 comments
Labels
bug Observed behavior contradicts documented or intended behavior upstream An issue with a third party project that Zig uses.
Milestone

Comments

@Dirreke
Copy link

Dirreke commented Jun 13, 2023

Zig Version

0.9.1

Steps to Reproduce and Observed Behavior

I use zig c++ -target arm-linux-gnueabihf -mcpu=generic+v7a+vfp3+d32+thumb2+neon -mfpu=neon -mfloat-abi=hard
and it still cann't add neon to target-feature, and I always get this

/opt/zig/zig-linux-x86_64-0.9.1/lib/include/arm_neon.h:32:2: error: "NEON support not enabled"

Is it a bug? Or maybe I just missed some args?

Expected Behavior

//

@Dirreke Dirreke added the bug Observed behavior contradicts documented or intended behavior label Jun 13, 2023
@leecannon
Copy link
Contributor

do you have the same issue with the latest stable zig release 0.10.1?

@Dirreke
Copy link
Author

Dirreke commented Jun 13, 2023

I cann't build for arm with 0.10.1 because #6573

  cargo:warning=warning(compilation): libc++ does not work on multi-threaded ARM yet.
  cargo:warning=For more details: https://github.com/ziglang/zig/issues/6573
  cargo:warning=error: unable to create compilation: TargetRequiresSingleThreaded
  exit status: 1

is there any way to build like rocksdb or Cbc with zig 0.10.1?

@iacore
Copy link
Contributor

iacore commented Jun 17, 2023

is there any way to build like rocksdb or Cbc with zig 0.10.1?

Can you use Clang?

@andrewrk
Copy link
Member

Zig is indeed passing the neon flags to Clang, so the question is why doesn't clang define the macro?

#if !defined(__ARM_NEON)
#error "NEON support not enabled"
#else

Can you file a bug report on Clang? Use ZIG_VERBOSE_CC=1 to observe the clang command that zig spits out (which includes -Xclang +neon) and ask them why __ARM_NEON is not defined.

@andrewrk andrewrk added downstream An issue with a third party project that uses Zig. upstream An issue with a third party project that Zig uses. and removed downstream An issue with a third party project that uses Zig. labels Jul 23, 2023
@andrewrk andrewrk added this to the 0.13.0 milestone Jul 23, 2023
@Dirreke
Copy link
Author

Dirreke commented Jul 23, 2023

I'd love to try it. However, I'm a little busy these days. I will try to find this bug some days later.

@Dirreke
Copy link
Author

Dirreke commented Jun 13, 2024

It issue seems very related to #10411

@ldube
Copy link

ldube commented Sep 25, 2024

(Tested on zig version 0.14.0-dev.1511+54b668f8a)

64bit ARMv8 defines __ARM_NEON and 32bit ARMv7 defines __ARM_FEATURE_SIMD32.

I used the commands below.

zig c++ -target aarch64-linux-gnueabihf  -x  c /dev/null -dM -E | grep -e SIMD -e NEON
#define __ARM_NEON 1
#define __ARM_NEON_FP 0xE

zig c++ -target arm-linux-gnueabihf  -x  c /dev/null -dM -E | grep -e SIMD -e NEON
#define __ARM_FEATURE_SIMD32 1

@alexrp
Copy link
Member

alexrp commented Sep 25, 2024

It seems that arm_neon.h now checks for __ARM_FP. Is it usable now?

@ldube
Copy link

ldube commented Sep 25, 2024

No. __ARM_NEON is checked because __ARM_FP is defined.

To make the program at the end compile, the check would have to be changed to this:
#if !defined(__ARM_NEON) && !defined(__ARM_FEATURE_SIMD32)

zig c++ -target arm-linux-gnueabihf -c hello.cpp


#include <arm_neon.h>

poly8x8_t atest(void) {
  poly8x8_t a;
  return splat_lane_p8(a, 0);
}

@alexrp
Copy link
Member

alexrp commented Sep 25, 2024

__ARM_NEON is checked

Where?

To make the program at the end compile

It compiles for me with those flags.

@ldube
Copy link

ldube commented Sep 25, 2024

I probably have an outdated build. I'll update and try again.

@alexrp
Copy link
Member

alexrp commented Sep 25, 2024

0.14.0-dev.1659+4ceefca14 here FWIW.

@ldube
Copy link

ldube commented Sep 25, 2024

Works with 0.14.0-dev.1651+ffd071f55

@alexrp alexrp closed this as completed Oct 2, 2024
@alexrp alexrp modified the milestones: 0.15.0, 0.14.0 Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

No branches or pull requests

6 participants