open-policy-agent / opa

Open Policy Agent (OPA) is an open source, general-purpose policy engine.
https://www.openpolicyagent.org
Apache License 2.0
9.44k stars 1.31k forks source link

the mac system does not support make to compile image #5509

Open fengshunli opened 1 year ago

fengshunli commented 1 year ago

executing make or make image will report an error image

DOCKER_UID=501 DOCKER_GID=20 /Library/Developer/CommandLineTools/usr/bin/make ci-go-ci-build-linux ci-go-ci-build-linux-static WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested clang++-13 -std=c++17 -MD -MP -nodefaultlibs --target=wasm32-unknown-unknown-wasm -fno-exceptions -fno-rtti -I src/lib -I src/libc++ -I /usr/lib/llvm-13/include/c++/v1 -I /usr/lib/llvm-13/lib/clang/13.0.0/include -I src/re2 -D_LIBCPP_HAS_NO_THREADS -D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION -O3 -c -o _obj/src/re2/re2/dfa.wasm src/re2/re2/dfa.cc In file included from src/re2/re2/dfa.cc:41: src/re2/util/mutex.h:37:14: error: no type named 'mutex' in namespace 'std' typedef std::mutex MutexType;


src/re2/util/mutex.h:96:36: error: member reference base type 'MutexType' (aka 'int') is not a structure or union
void Mutex::Lock()         { mutex_.lock(); }
                             ~~~~~~^~~~~
src/re2/util/mutex.h:97:36: error: member reference base type 'MutexType' (aka 'int') is not a structure or union
void Mutex::Unlock()       { mutex_.unlock(); }
                             ~~~~~~^~~~~~~
3 errors generated.
make: *** [Makefile:135: _obj/src/re2/re2/dfa.wasm] Error 1
make[2]: *** [build] Error 2
make[1]: *** [wasm-lib-build] Error 2
make: *** [image] Error 2
srenatus commented 1 year ago

Can you please copy-paste the output? It's illegible. Also, from our Slack conversation, it's an M1-related issue.

fengshunli commented 1 year ago

Can you please copy-paste the output? It's illegible. Also, from our Slack conversation, it's an M1-related issue.

ok,my system is m2

stale[bot] commented 1 year ago

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

stale[bot] commented 1 year ago

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

anderseknert commented 9 months ago

Let us know if this is still an issue, but since we've not seen reports from others on Mac, I think we can close this for now.

dxh9845 commented 4 months ago

For what it's worth, I am seeing the same. Will check the Slack channel to see how this was resolved:

src/re2/util/mutex.h:37:14: error: no type named 'mutex' in namespace 'std'
typedef std::mutex MutexType;
        ~~~~~^
src/re2/util/mutex.h:96:36: error: member reference base type 'MutexType' (aka 'int') is not a structure or union
void Mutex::Lock()         { mutex_.lock(); }
                             ~~~~~~^~~~~
src/re2/util/mutex.h:97:36: error: member reference base type 'MutexType' (aka 'int') is not a structure or union
void Mutex::Unlock()       { mutex_.unlock(); }
                             ~~~~~~^~~~~~~
3 errors generated.
make: *** [Makefile:135: _obj/src/re2/re2/dfa.wasm] Error 1
anderseknert commented 4 months ago

Thanks! Re-opening.

srenatus commented 4 months ago

Hmm curious! The compilation of C-to-Wasm happens inside a docker container, so it's surprising if something there changes just like that.

dxh9845 commented 4 months ago

So I rebuilt the OPA wasm builder image and used that - still received the same result. I would suspect this is something to do with Docker Platform architectures - I'm running on a Macbook Pro M2.

I do set the DOCKER_DEFAULT_PLATFORM environment variable to build for Linux AMD64.

env | rg 'DOCKER'
DOCKER_DEFAULT_PLATFORM=linux/amd64
stale[bot] commented 3 months ago

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.

RohitRox commented 4 weeks ago

Just tried to build this in my system and tried to run tests. I was hit the same error. I am on Intel Macbook Pro.

clang++-13 -std=c++17 -MD -MP -nodefaultlibs --target=wasm32-unknown-unknown-wasm -fno-exceptions -fno-rtti -I src/lib -I src/libc++ -I /usr/lib/llvm-13/include/c++/v1 -I /usr/lib/llvm-13/lib/clang/13.0.0/include -I src/re2 -D_LIBCPP_HAS_NO_THREADS -D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION -O3 -c -o _obj/src/re2/re2/dfa.wasm src/re2/re2/dfa.cc
In file included from src/re2/re2/dfa.cc:41:
src/re2/util/mutex.h:37:14: error: no type named 'mutex' in namespace 'std'
typedef std::mutex MutexType;
        ~~~~~^
src/re2/util/mutex.h:96:36: error: member reference base type 'MutexType' (aka 'int') is not a structure or union
void Mutex::Lock()         { mutex_.lock(); }
                             ~~~~~~^~~~~
src/re2/util/mutex.h:97:36: error: member reference base type 'MutexType' (aka 'int') is not a structure or union
void Mutex::Unlock()       { mutex_.unlock(); }
                             ~~~~~~^~~~~~~
3 errors generated.
make: *** [Makefile:135: _obj/src/re2/re2/dfa.wasm] Error 1