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

Brew doesn't check architecture when cross-compiling #5028

Closed
SirLynix opened this issue Apr 28, 2024 · 5 comments
Closed

Brew doesn't check architecture when cross-compiling #5028

SirLynix opened this issue Apr 28, 2024 · 5 comments
Labels
Milestone

Comments

@SirLynix
Copy link
Member

Xmake Version

2.9.1

Operating System Version and Architecture

macOS GitHub CI

Describe Bug

When xmake checks for a package in brew on macOS, it doesn't check if the architecture matches.

If I'm not wrong, brew matches the host architecture (ARM for recent macOS) but xmake will try to find a poackage on brew if cross-compiling, resulting in found package but failed linking.

Expected Behavior

That xmake doesn't take packages in brew that don't match current architecture (I don't know how it can get this info as macOS supports multi-arch libs)

Project Configuration

should happen with using sfml on macOS ARM and targetting x86_64

add_requires("sfml")

target("foo")
    add_files("src/main.cpp")
    add_packages("sfml")

Additional Information and Error Logs

https://github.com/NazaraEngine/ShaderLang/actions/runs/8870545303/job/24352454378?pr=40

Run xmake config --arch=x86_64 --mode=debug --kind=static --ccache=n --examples=y --tests=y --unitybuild=y --yes
checking for platform ... macosx
checking for Xcode directory ... /Applications/Xcode.app
checking for Codesign Identity of Xcode ... no
checking for SDK version of Xcode for macosx (x8[6](https://github.com/NazaraEngine/ShaderLang/actions/runs/8870545303/job/24352454378?pr=40#step:9:7)_64) ... 14.0
checking for Minimal target version of Xcode for macosx (x86_64) ... 14.0
  => download https://gitlab.com/eidheim/tiny-process-library/-/archive/v2.0.4/tiny-process-library-v2.0.4.tar.gz .. ok
  => download https://github.com/catchorg/Catch2/archive/refs/tags/v3.5.4.zip .. ok
  => download https://github.com/xmake-mirror/xmake-cacert/archive/refs/tags/2024020[7](https://github.com/NazaraEngine/ShaderLang/actions/runs/8870545303/job/24352454378?pr=40#step:9:8).zip .. ok
  => install ca-certificates 20240207 .. ok
  => download https://github.com/KhronosGroup/SPIRV-Headers/archive/refs/tags/vulkan-sdk-1.3.275.0.tar.gz .. ok
  => download https://www.python.org/ftp/python/3.11.[8](https://github.com/NazaraEngine/ShaderLang/actions/runs/8870545303/job/24352454378?pr=40#step:9:9)/Python-3.11.8.tgz .. ok
checking for SDK version of Xcode for macosx (arm64) ... 14.0
checking for Minimal target version of Xcode for macosx (arm64) ... 14.0
  => install spirv-headers 1.3.275+0 .. ok
  => download https://github.com/SFML/SFML/archive/refs/tags/2.6.0.tar.gz .. ok
  => install tiny-process-library v2.0.4 .. ok
  => download https://github.com/fmtlib/fmt/releases/download/[10](https://github.com/NazaraEngine/ShaderLang/actions/runs/8870545303/job/24352454378?pr=40#step:9:11).2.1/fmt-10.2.1.zip .. ok
  => install fmt 10.2.1 .. ok
  => clone https://github.com/NazaraEngine/NazaraUtils.git 2024.04.04 .. ok
  => install nazarautils 2024.04.04 .. ok
  => download https://github.com/fastfloat/fast_float/archive/refs/tags/v6.1.1.tar.gz .. ok
  => install fast_float v6.1.1 .. ok
  => download https://github.com/serge-sans-paille/frozen/archive/refs/tags/1.1.1.tar.gz .. ok
  => install frozen 1.1.1 .. ok
  => download https://github.com/Tessil/ordered-map/archive/refs/tags/v1.1.0.tar.gz .. ok
  => install ordered_map v1.1.0 .. ok
  => download https://github.com/SpartanJ/efsw/archive/refs/tags/1.3.1.tar.gz .. ok
  => install efsw 1.3.1 .. ok
  => download https://github.com/jarro2783/cxxopts/archive/v3.2.1.tar.gz .. ok
  => install catch2 v3.5.4 .. ok
  => install sfml 2.6.0 .. failed

ld: warning: ignoring file '/opt/homebrew/Cellar/freetype/2.[13](https://github.com/NazaraEngine/ShaderLang/actions/runs/8870545303/job/24352454378?pr=40#step:9:14).2/lib/libfreetype.6.dylib': found architecture 'arm64', required architecture 'x86_64'
ld: Undefined symbols:
  _FT_Bitmap_Embolden, referenced from:
      sf::Font::loadGlyph(unsigned int, unsigned int, bool, float) const in libsfml-graphics-s.a[4](Font.cpp.o)
  _FT_Done_Face, referenced from:
      sf::Font::cleanup() in libsfml-graphics-s.a[4](Font.cpp.o)
      sf::Font::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in libsfml-graphics-s.a[4](Font.cpp.o)
      sf::Font::loadFromMemory(void const*, unsigned long) in libsfml-graphics-s.a[4](Font.cpp.o)
      sf::Font::loadFromStream(sf::InputStream&) in libsfml-graphics-s.a[4](Font.cpp.o)
      sf::Font::loadFromStream(sf::InputStream&) in libsfml-graphics-s.a[4](Font.cpp.o)
  _FT_Done_FreeType, referenced from:
      sf::Font::cleanup() in libsfml-graphics-s.a[4](Font.cpp.o)
  _FT_Done_Glyph, referenced from:
      sf::Font::loadGlyph(unsigned int, unsigned int, bool, float) const in libsfml-graphics-s.a[4](Font.cpp.o)
  _FT_Get_Char_Index, referenced from:
      sf::Font::getGlyph(unsigned int, unsigned int, bool, float) const in libsfml-graphics-s.a[4](Font.cpp.o)
      sf::Font::hasGlyph(unsigned int) const in libsfml-graphics-s.a[4](Font.cpp.o)

here freetype is not installed as it's found on the system

@SirLynix SirLynix added the bug label Apr 28, 2024
@waruqi
Copy link
Member

waruqi commented Apr 29, 2024

you can debug here and improve is_cross.

if is_cross(opt.plat, opt.arch) then

@SirLynix
Copy link
Member Author

How can I debug this on Github CI? I don't have a macOS at home

@waruqi
Copy link
Member

waruqi commented Apr 29, 2024

How can I debug this on Github CI? I don't have a macOS at home

new a test branch for xmake and add some logs. then switch to your branch in ci.

@SirLynix
Copy link
Member Author

SirLynix commented May 1, 2024

the problem seems to come from pkgconfig:

find_package pkgconfig::freetype2
opt.plat macosx
opt.arch x86_64
--
macosx
x86_64
--
finding freetype2 from pkgconfig ..
found freetype2
{ 
  includedirs = { 
    "/opt/homebrew/opt/freetype/include/freetype2",
    "/opt/homebrew/opt/libpng/include/libpng16",� 
  },
  linkdirs = { 
    "/opt/homebrew/opt/freetype/lib",� 
  },
  version = "26.1.20",
  links = { 
    "freetype",� 
  },� 
}
{ 
  "/opt/homebrew/opt/freetype/lib",� 
}
{ 
  "freetype",� 
}
checking for pkgconfig::freetype2 ... freetype2 26.1.20

(on a macOS arm64 runner, full log)

should be fixed by #5039

waruqi added a commit that referenced this issue May 1, 2024
pkgconfig: don't find packages when cross-compiling (fix #5028)
@waruqi
Copy link
Member

waruqi commented May 1, 2024

merged

@waruqi waruqi closed this as completed May 1, 2024
@waruqi waruqi added this to the v2.9.2 milestone May 1, 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