Skip to content

OS X 10.10 using '-march=native' works in clang but breaks in gcc #748

@certik

Description

@certik

More background e.g. in Homebrew/legacy-homebrew#14204.
The way it breaks in (our compiled) gcc is as follows:

[csympy] Building CXX object src/CMakeFiles/csympy.dir/symbol.cpp.o
[csympy] /var/tmp//ccc4Ii22.s:829:no such instruction: `vzeroupper'
[csympy] /var/tmp//ccc4Ii22.s:847:no such instruction: `vzeroupper'
[csympy] /var/tmp//ccc4Ii22.s:855:no such instruction: `vzeroupper'
...

The linker (which is Apple linker) complains that it doesn't understand the AVX instructions, emitted (correctly) by gcc's -march=native, since my computer supports AVX. A quick workaround is to do

diff --git a/pkgs/csympy.yaml b/pkgs/csympy.yaml
index 5caa557..32bf39d 100644
--- a/pkgs/csympy.yaml
+++ b/pkgs/csympy.yaml
@@ -12,6 +12,12 @@ defaults:
   relocatable: false

 build_stages:
+- name: cxx_flags
+  before: configure
+  handler: bash
+  bash: |
+    export CXXFLAGS="-mno-avx"
+
 - name: configure
   extra: ['-D WITH_PYTHON:BOOL=ON',
           '-D PYTHON_INSTALL_PATH:PATH=$ARTIFACT/{{python_site_packages_rel}}']

But this is not a solution, because you want to be able to use AVX instructions if your processor supports it, and gcc generates them, i.e. you must be able to use -march=native.

The fix is to either make gcc generate AVX instructions so that the Apple's linker can understand, or we need to build our own linker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions