macOS d_fat arch detection using Xcode version#69
macOS d_fat arch detection using Xcode version#69danomatika wants to merge 12 commits intomasterfrom
Conversation
|
Oh and I can confirm |
This is because the variable defined in the makefile is overridden by the last definition (the default platform extension), while a variable definition from command line has precedence over the makefile. One solution would be to define default extension conditionally in Makefile.pdlibbuilder (i.e. on the condition that it wasn't defined yet). |
Done: |
|
A (possibly welcome) side effect is that |
|
a gut feeling tells me to agree with katja that we should avoid envirnment variables whenever possible. (esp. if they have such a generic name as |
|
I agree that it would be better not to expose too many internal variables, when possible. I started with using what was already there, namely setting A better approach would be a simple boolean like ifeq ($(system), Darwin)
...
extension = pd_darwin
ifdef fat-libs
extension = d_fat
endif
ifeq ($(extension), d_fat)
# set arches from Xcode version
...
endif
...
endifThe making a # build macOS fat lib
define forDarwin
fat-libs
endefor even just the switch as it would only be used for build systems which support it: fat-libsPerhaps a better name could be |
…extension, moved usage into tips and tricks md
|
Ok, now the |
|
hmm, this seems to be a regression to me. the current behaviour is to build fat binaries if why do we now need a separate switch? |
Hrmm, well Katja wrote:
and you wrote:
So I read that as "we don't want to use extension for this" and as there is already a similar convention with |
|
Making ifeq ($(origin extension), undefined)
extension = pd_darwin
ifeq ($(make-lib-fat),yes)
extension = d_fat
endif
endifThen |
ah, i read this: "we don't want to use environment-variables for this".
|
|
Regarding the supported architecture detection, we can also use the macOS version such as used in the libpd makefile: https://github.com/libpd/libpd/blob/master/Makefile#L16 |
|
using the macOS version doesn't strike me as particularly correct. ideally we should ask the compiler what it supports (but that gets quickly down the road towards autotools/cmake/...) |
|
What do you think @katjav? Should I return it to |
Introducing a proper switch for building fat binaries seems a good thing to do if it doesn't break current behavior, but notice that (By the way I doubt whether a lib makefile should build non-native architectures without explicit user interference.) |
|
Would |
Actually, this is less of a problem for my use case as I have another makefile calling the individual external makefiles, so I can set the flag/variable there. EDIT: One issue is that if you forget to pass the flag/variable, running the |
That is consistent indeed, excellent. |
Calling submake process is a command line so you can override makefile definitions after all. |
|
Ok, switch renamed to "make-multi-arch" and I removed the tips & tricks reference to overriding the internal As to IOhannes' point earlier:
This still works. |
That is a general consequence with non-default build products, also with multi-class lib or alternative extension; you have to specify the same for targets |
|
@danomatika do you have access to old setups for testing all detection cases? We also need to be sure that cross-compilation still works as before. |
|
@katjav I am working from home and have 3 laptops available here, but nothing too old:
I see also that relying on detecting the CLITools installed will not work with older versions of Xcode in 10.6 and possibly 10.7, so I will also add checking the output of UPDATE: This should also handle the case for systems which have Xcode installed from the App Store without installing the separate CLI tools package. For people who only compile on the command line, it's more likely they will only have the CLI Tools installed, for example as we suggest in the Pure Data INSTALL.txt. |
What cross-compilation setups are there for macOS... via Linux? UPDATE: As far as I can tell looking through the new behavior, everything should still build as before, except that there will be a warning printed if Xcode is not detected and the old default architectures of UDPATE2: I also don't think I'm inadvertently using any newer Make-isms than what is already there, ie. chained "else ifeq" etc. |
On Linux indeed it is possible to cross-build for MacOs using this project: https://github.com/tpoechtrager/osxcross In 2019 I was, for a short while, ambitious about a "one-click-build" method to get Pd externals for "all" platforms (obviously not including arm64 for Mac): https://github.com/electrickery/pd-dekencross I could try retrieve my cross-build setup to see how it behaves with your detection method. |
|
When this PR is merged, can the commits be squashed? There quite a few back & forth commits in there. |
|
This PR is working for me with our (customized) externals in https://github.com/zkmkarlsruhe/ZirkoniumSpatializationServer/tree/update/external-sources. Let me know if there are other changes needed. |
|
As related to the discussion at #51, does anyone think the solution in this PR is getting too complicated? Should I/we think of a simpler approach which relies more on library developers, ie. no simple flag but specify the architectures manual via something like ifeq ($(origin extension), undefined)
# chooses extension d_fat automatically when set
multi-arch = arm64 x86_64
endifThis relies a bit more on documenting the flags, but they are simple enough. OTOH we use a similar Xcode version detection already in the libpd makefile for a couple of years now and there haven't been any major issues yet. However it could be a (small) maintenance point as Apple shifts their SDKs around, although I think things are stable enough after the move to the bundled Xcode.app and separate Command Line Tools around OSX 10.7. |
|
i think this is different from #51, as there is typically no problem with building for a given architecture as long as the compiler supports it (unlike the i cannot think of a reason why anybody would actively want to prevent a build for powerpc or arm64. |
|
Does this need any updates? |
|
I just fixed a bug where detecting the Xcode version using |
|
I'm closing this for now as it appears to be going nowhere. I would suggest, at a minimum, removing the extension handling which checks for In any case, the current solution I am now using is to explicitly set |
|
What if we just replace the outdated On the other hand I don't know if pdlibbuilder should define architectures or even extension when "fat binary" is ambiguous. |
i tend to agree. this PR was an attempt to lift the targetting to the tools, but these are still moving. |
This PR adds auto detection of the available target architectures when performing a "fat lib" build on macOS. An override is also provided if the
archvariable is set when building.Note: I notice that if I try to set the extension variable to trigger the fat lib build, it will only work from the command line and not from within a Makefile. I'd like to be able to do the following:
EDIT: The Xcode version detection comes from Caffee.
Also, I'm pretty sure
pkgutilis available all the way back to OSX 10.6 as the man page is dated March 2011 and 10.7 was release in summer of 2011. Can someone try on a 10.6 machine to make sure?