Description: |
Hi, in MacPorts we build tk using the `--enable-64bit` configure flag
when we are doing a 64-bit build. I believe we are doing this because we
saw that the flag existed and we assumed we should set it.
It has come to our attention that this is causing a problem when trying
to do *universal* builds (i.e. builds for multiple architectures). See
https://trac.macports.org/ticket/71415.
When building universal, we build for each architecture separately and
then combine the results using `lipo` and other methods. For example, we
configure and build with `-arch x86_64` in CFLAGS, LDFLAGS, etc., and
then we configure and build again in a different directory with `-arch
arm64`. I am not certain why we build tk this way since it is not our
usual method, but it might be because we wanted to be sure to supply
`--enable-64bit` only when configuring for 64-bit architectures and not
when configuring for 32-bit architectures.
The problem arises when the configure script decides to add `-arch`
flags we didn't want. On an Intel Mac it adds `-arch x86_64` even when
we are trying to build the arm64-only slice and on an Apple Silicon Mac
it adds `-arch arm64` when we are trying to build the x86_64-only slice.
The question is how we should resolve this. Should we simply stop using
`--enable-64bit` at all? Is its only function to add the `-arch` flags
that we don't want? Or does it do other things that are required for a
64-bit build? For example, I see that it defines `TCL_CFG_DO64BIT` to 1.
Is that of any significance? If so, would it be sufficient (and
sufficiently future-proof) for us to define `TCL_CFG_DO64BIT` to 1
manually in CFLAGS on 64-bit architectures?
I see that `-DTCL_CFG_DO64BIT=1` appears in the `TK_DEFS` line of the
installed tkConfig.sh file on my 64-bit system. I don't know how that's
expected to work if this were a 32-bit/64-bit universal build. Who
consumes these `TK_DEFS`? What do they expect to find here with regard
to bitness? How do they use that information?
Do you have any experience with universal builds on macOS? If so, is it
your belief that a "simple" universal build (one which supplies multiple
`-arch` flags at once, e.g. `-arch arm64 -arch x86_64`) should work for
tk?
|
User Comments: |
marc_culler (claiming to be Marc Culler) added on 2025-01-22 02:49:37:
> Do you have any experience with universal builds on macOS?
Yes
> If so, is it
> your belief that a "simple" universal build (one which supplies multiple
> `-arch` flags at once, e.g. `-arch arm64 -arch x86_64`) should work for
> tk?
Yes, absolutely. For example, I normally build with the commands:
export CFLAGS="-arch x86_64 -arch arm64 -mmacos-version-min=10.3"
make -C macosx
This builds a universal2 framework for x86_64 and arm64 which works on
macOS 10.13 and up. (But apparently there is an issue if your build
system is running 10.13.)
|