Open alecazam opened 2 weeks ago
Also tried response files to workaround the 1 argument limit of -Xarch. But this doesn't work either. Says the argument is unused.
PRECOMPILED_CXXFLAGS += \ -Xarch_arm64 @$(PRECOMPILED_PCH_ARM).in \ -Xarch_x86_64 @$(PRECOMPILED_PCH_X64).in \
So macOS clang seems to have left out multiarch support for precompiled headers. So I split out our arch specifications as such, and compiled each pch for each arch. I've left the trailing backslash off on the examples below just because they don't carry over without using a double-backslash.
Given that Win/Android/Linux now has arm64 and x64, this would be good to fix if this is pervasive across other platforms.
CXXARCH := -arch x86_64 -mavx2 -mf16c -mfma -arch arm64
The problem is now I need to pass the pch to the compiles. This requires use of -include-pch like so.
PRECOMPILED_CXXFLAGS += -include-pch $(PRECOMPILED_PCH_ARM) -include-pch $(PRECOMPILED_PCH_X64)
But that doesn't work since it tries to link the x64 pch to the .o. So then I try -Xarch
PRECOMPILED_CXXFLAGS += -Xarch_arm64 -include-pch $(PRECOMPILED_PCH_ARM) -Xarch_x86_64 -include-pch $(PRECOMPILED_PCH_X64)
That generates the following failure: invalid Xarch argument: '-Xarch_arm64 -include-pch', options requiring arguments are unsupported
I also tried this to workaround the single argument limit of -Xarch, but then get a complaint about using -o with multiple arch. But I don't get that if I just leave the pch out, and it builds the universal lib/exe just fine. The -o is still on the command line.
PRECOMPILED_CXXFLAGS += -include-pch -Xarch_arm64$(PRECOMPILED_PCH_ARM) -Xarch_x86_64 $(PRECOMPILED_PCH_X64)
clang++:1:1 cannot specify -o when generating multiple output files
Trying to turn it into a single arg, clang seems to think this is a -include directive, and tries to prepend the AST (.pch) with the filename -pch=... which is also not correct parsing and hangs the parser.
PRECOMPILED_CXXFLAGS += \ -Xarch_arm64 -include-pch=$(PRECOMPILED_PCH_ARM)\ -Xarch_x86_64 -include-pch=$(PRECOMPILED_PCH_X64)\
So I have no idea how to fix multiarch and pch. I can build multiarch without pch. I can build each arch separately. The -Xarch limitation is very limiting.