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

Resolve wheel build failure on x86_64 architecture due to -march=native flag #455

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

XiChenn
Copy link

@XiChenn XiChenn commented Apr 22, 2023

The hnswlib wheel build failed on my MacOS (x86_64 architecture) when I run pip install hnswlib.

      clang: error: the clang compiler does not support '-march=native'
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for hnswlib
Failed to build hnswlib
ERROR: Could not build wheels for hnswlib, which is required to install pyproject.toml-based projects

Similar to the solution of the previous merged PR, by removing the building flag resolves the issue.

pip install .
Looking in indexes: https://pypi.python.org/simple/
...
Successfully built hnswlib
Installing collected packages: hnswlib
Successfully installed hnswlib-0.7.0

@yurymalkov
Copy link
Member

yurymalkov commented Apr 23, 2023

Hm. I can imagine this would remove native optimizations from linux builds - I see it only uses Darwin
Do I understand what is causing the problem? Is it due to clang?

@yurymalkov
Copy link
Member

We can try to understand if the compiler is clang with something like

import sys
import platform
import subprocess
import re

def is_clang_compiler():
    try:
        # Run the compiler version command
        result = subprocess.run(['cc', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
        output = result.stdout.lower()

        # Check if the output contains the word 'clang'
        return 'clang' in output
    except FileNotFoundError:
        # If the 'cc' command is not found, it's not Clang
        return False

@yurymalkov
Copy link
Member

Can you double check that your compiler is set up properly? I've added macos to the CI with x64 and the tests are passing.
I am also confused that your error message has both gcc and clang mentioned, sounds fishy

@XiChenn
Copy link
Author

XiChenn commented May 1, 2023

My Mac is 2019 version.
see the result below:

>>> result = subprocess.run(['cc', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
>>> output = result.stdout.lower()
>>> output
'apple clang version 14.0.3 (clang-1403.0.22.14.1)\ntarget: x86_64-apple-darwin22.4.0\nthread model: posix\ninstalleddir: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin\n'

@dyashuni
Copy link
Contributor

@XiChenn Could you please try pip install . from PR #461 ?
it should fix your issue

@yurymalkov
Copy link
Member

@XiChenn Can you check if the other change fixes your problem by running pip install git+https://github.com/nmslib/hnswlib.git@refs/pull/461/head?

@cterrazas2
Copy link

fwiw, @yurymalkov I was having the same issue as @XiChenn (Mac x86_64 architecture) and installing via #461's head worked for me.

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

Successfully merging this pull request may close these issues.

4 participants