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] Needs true GCC from Homebrew, not Clang "gcc" #131

Closed
jeongyunl opened this issue Jan 24, 2024 · 2 comments
Closed

[macOS] Needs true GCC from Homebrew, not Clang "gcc" #131

jeongyunl opened this issue Jan 24, 2024 · 2 comments
Labels

Comments

@jeongyunl
Copy link

resolve-march-native fails on macOS 14.2 with this error:
ERROR: Command '['gcc', '-Q', '--help=target', '-mcpu=native']' returned non-zero exit status 1.

Environment:

% uname -a
Darwin jlee-mbair.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:59:33 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8112 arm64

% gcc --version
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

% gcc -### -E -march=native -  
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "-cc1" "-triple" "arm64-apple-macosx14.0.0" "-Wundef-prefix=TARGET_OS_" "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" "-Werror=implicit-function-declaration" "-E" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "-" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" "-fno-strict-return" "-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=1" "-fobjc-msgsend-selector-stubs" "-target-sdk-version=14.2" "-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "apple-m1" "-target-feature" "+neon" "-target-feature" "+v8.5a" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-abi" "darwinpcs" "-debugger-tuning=lldb" "-target-linker-version" "1022.1" "-fcoverage-compilation-dir=/Users/jeongyun" "-resource-dir" "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" "-I/usr/local/include" "-internal-isystem" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include" "-internal-isystem" "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include" "-internal-externc-isystem" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include" "-internal-externc-isystem" "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include" "-Wno-reorder-init-list" "-Wno-implicit-int-float-conversion" "-Wno-c99-designator" "-Wno-final-dtor-non-final-class" "-Wno-extra-semi-stmt" "-Wno-misleading-indentation" "-Wno-quoted-include-in-framework-header" "-Wno-implicit-fallthrough" "-Wno-enum-enum-conversion" "-Wno-enum-float-conversion" "-Wno-elaborated-enum-base" "-Wno-reserved-identifier" "-Wno-gnu-folding-constant" "-fdebug-compilation-dir=/Users/jeongyun" "-ferror-limit" "19" "-stack-protector" "1" "-fstack-check" "-mdarwin-stkchk-strong-link" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fmax-type-align=16" "-fcommon" "-fcolor-diagnostics" "-clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation" "-fno-odr-hash-protocols" "-clang-vendor-feature=+enableAggressiveVLAFolding" "-clang-vendor-feature=+revert09abecef7bbf" "-clang-vendor-feature=+thisNoAlignAttr" "-clang-vendor-feature=+thisNoNullAttr" "-mllvm" "-disable-aligned-alloc-awareness=1" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "-" "-x" "c" "-"

Debug output

$ resolve-march-native --debug
# gcc -S -fverbose-asm -o /dev/stdout /var/folders/7s/ypkmzhkm8xg2p3001s6lqcqh0000gn/T/tmp_i64nlde.c -march=native
Flags extracted: 
# gcc -Q --help=target -march=native
clang: error: unsupported option '--help=target'
clang: error: no input files
# gcc -Q --help=target -mcpu=native
clang: error: unsupported option '--help=target'
clang: error: no input files
Traceback (most recent call last):
  File "/Users/jeongyun/Library/Python/3.9/lib/python/site-packages/resolve_march_native/target_help_parser.py", line 96, in get_flags_implied_by_march
    gcc_output = subprocess.check_output(cmd, env=env, stderr=stderr).decode('UTF-8')
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['gcc', '-Q', '--help=target', '-march=native']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jeongyun/Library/Python/3.9/lib/python/site-packages/resolve_march_native/__main__.py", line 50, in _inner_main
    native_unrolled_flag_set = Engine(
  File "/Users/jeongyun/Library/Python/3.9/lib/python/site-packages/resolve_march_native/engine.py", line 133, in run
    march_native_flag_set = self._get_march_native_flag_set()
  File "/Users/jeongyun/Library/Python/3.9/lib/python/site-packages/resolve_march_native/engine.py", line 67, in _get_march_native_flag_set
    march_native_flag_set |= set(get_flags_implied_by_march('native', gcc=self._gcc_command,
  File "/Users/jeongyun/Library/Python/3.9/lib/python/site-packages/resolve_march_native/target_help_parser.py", line 101, in get_flags_implied_by_march
    gcc_output = subprocess.check_output(cmd, env=env, stderr=stderr).decode('UTF-8')
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['gcc', '-Q', '--help=target', '-mcpu=native']' returned non-zero exit status 1.
ERROR: Command '['gcc', '-Q', '--help=target', '-mcpu=native']' returned non-zero exit status 1.

@hartwork
Copy link
Owner

@jeongyunl to my best knowledge resolve-march-native needs true GCC which means GCC from homebrew on macOS. The CI covers that case, as of today Clang is not supported and your "gcc" is Clang in disguise. Is https://formulae.brew.sh/formula/gcc an option to you?

@jeongyunl
Copy link
Author

@hartwork Thanks for quick reply.
I was just trying to figure out how to determine the l1 cache line size of a target platform.
I think I'll just stick to sysctl or getconf.

@hartwork hartwork changed the title resolve-march-native fails on macOS 14.2: ERROR: Command '['gcc', '-Q', '--help=target', '-mcpu=native']' returned non-zero exit status 1. [macOS] Needs true GCC from homebrew, not Clang "gcc" Jan 24, 2024
@hartwork hartwork pinned this issue Jan 24, 2024
@hartwork hartwork changed the title [macOS] Needs true GCC from homebrew, not Clang "gcc" [macOS] Needs true GCC from Homebrew, not Clang "gcc" Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants