premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

architecture ignored on macOS

Open bhundt opened this issue 2 years ago • 2 comments

See below or discussion here https://github.com/premake/premake-core/discussions/2123.

Discussed in https://github.com/premake/premake-core/discussions/2123

Originally posted by bhundt August 11, 2023 I am working on an M1 Mac running 13.3.1. I want to cross-compile to a target architecture of x86_64 and for that I tried the sample premake project and adapted the premake file as follows:

workspace "HelloWorld"
   configurations { "Debug", "Release" }
   architecture "x86_64"

project "HelloWorld"
   kind "ConsoleApp"
   language "C++"
   cppdialect "C++20"
   targetdir "bin/%{cfg.buildcfg}"

   files { "**.hpp", "**.h", "**.cpp" }

   filter "configurations:Debug"
      defines { "DEBUG" }
      symbols "On"

   filter "configurations:Release"
      defines { "NDEBUG" }
      optimize "Speed"

Unfortunately this creates the default architecture of arm64 which I checked using the lipo -info command.

When I add

buildoptions "-arch x86_64"
linkoptions "-arch x86_64"

then the lipo -info command shows a x86_64 build is generated.

bhundt avatar Sep 08 '23 11:09 bhundt

Same happens to me! It seems that premake is only adding -m64 on ALL_LDDFLAGS but it is also needed the -arch x86_64 on CFLAGS and LDDFLAGS

perseoGI avatar Apr 08 '25 15:04 perseoGI

Same for me.

https://github.com/mercury233/premake-macos-arch-test/blob/main/premake5.lua

Image

Image

mercury233 avatar Apr 28 '25 06:04 mercury233

This should be resolved with #2502.

samsinsane avatar Sep 14 '25 03:09 samsinsane