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

Building cmake library, I meet bug: "#error this header is for x86 only" #9363

Closed
Basasuya opened this issue Aug 31, 2019 · 2 comments
Closed

Comments

@Basasuya
Copy link

I try to build a cmake library into llvm bitcode. the target library is ogdf, My environment is Mac OS(mojave), emcc -v shows below:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.42
clang version 6.0.1 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-emscripten--core-emscripten--fastcomp--clang 98df4be387dde3e3918fa5bbb5fc43e1a0e1daac) (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-emscripten--core-emscripten--fastcomp 1b4148f39a69c7fc62edadd85e4122b68694dfb7) (emscripten 1.38.31 : 1.38.31)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Users/basasuya/emsdk/fastcomp/fastcomp/bin
shared:INFO: (Emscripten: Running sanity checks)

then I run the following command

mkdir build && cd build
emconfigure cmake ..
emmake make

then I got errors:

clang-6.0: error: argument unused during compilation: '-march=native' [-Werror,-Wunused-command-line-argument]

then I modify the file and make this line as a Comment. After modifiction, I run the previous build commands again, then I got the following error.

/Users/basasuya/emsdk/fastcomp/fastcomp/lib/clang/6.0.1/include/cpuid.h:25:2: error: this header is for x86 only
#error this header is for x86 only
 ^
/Users/basasuya/emsdk/fastcomp/fastcomp/lib/clang/6.0.1/include/cpuid.h:271:5: error: invalid output constraint '=a' in asm
    __cpuid(__leaf, __eax, __ebx, __ecx, __edx);
    ^
/Users/basasuya/emsdk/fastcomp/fastcomp/lib/clang/6.0.1/include/cpuid.h:236:11: note: expanded from macro '__cpuid'
        : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \
          ^
/Users/basasuya/emsdk/fastcomp/fastcomp/lib/clang/6.0.1/include/cpuid.h:286:5: error: invalid output constraint '=a' in asm
    __cpuid(__leaf, *__eax, *__ebx, *__ecx, *__edx);
    ^
/Users/basasuya/emsdk/fastcomp/fastcomp/lib/clang/6.0.1/include/cpuid.h:236:11: note: expanded from macro '__cpuid'
        : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \
          ^
/Users/basasuya/emsdk/fastcomp/fastcomp/lib/clang/6.0.1/include/cpuid.h:300:5: error: invalid output constraint '=a' in asm
    __cpuid_count(__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);
    ^
/Users/basasuya/emsdk/fastcomp/fastcomp/lib/clang/6.0.1/include/cpuid.h:243:11: note: expanded from macro '__cpuid_count'
        : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \
          ^
4 errors generated.

Now I have no idea about how to fix it. Can anyone help me?

@embeddedt
Copy link

It definitely doesn't make sense to include cpuid.h, since the target CPU architecture is unknown on a web page (I think).

Do you know where cpuid.h is being included from?

@Basasuya
Copy link
Author

Basasuya commented Sep 6, 2019

@embeddedt I find the location where cpuid.h locates. Then modifed ogdf/include/ogdf/basic/internal/config.h and add #undef __GNUC__ to force the library not to use this file. The result is it works and I successfully run my code and achieve the goal.

Thank you very much for your advice sincerely!

@Basasuya Basasuya closed this as completed Sep 6, 2019
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

2 participants