-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add C++ makefile flags support. #752
Comments
@Lessica would you mind sharing your makefile? Myself and one other have attempted to replicate both your and Ilan's error and cannot. Thanks! |
I moved all C++ sources to another build target |
Something may be incorrect in your setup then because your previous image shows the flag being passed to ObjC (.m) files which is odd considering XXX_CCFLAGS does not apply to .m files theos/makefiles/instance/rules.mk Line 276 in 697afd9
If you wouldn't mind, it may help to see the full makefile |
See |
To replicate this problem, you need Xcode 13.2.1 or earlier versions. Here is my ARCHS := arm64
TARGET := iphone:clang:15.5:13.0
SYSROOT := /Applications/Xcode-13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.5.sdk
include $(THEOS)/makefiles/common.mk
TOOL_NAME := ngtool
ngtool_FILES += Entry.swift
ngtool_FILES += $(wildcard Commands/*.swift)
ngtool_FILES += $(wildcard Errors/*.swift)
ngtool_FILES += $(wildcard Extensions/*.swift)
ngtool_FILES += $(wildcard Library/*.swift)
ngtool_FILES += $(wildcard Models/*.swift)
ngtool_FILES += $(wildcard Wrapper/*.m)
ngtool_FILES += $(wildcard Wrapper/*.mm)
ngtool_FILES += $(wildcard SwiftWrapper/*.swift)
ngtool_FILES += ../shared/TFLuaBridge+Shell.mm
ngtool_CFLAGS += -fobjc-arc
ngtool_CFLAGS += -DXXT_VERSION=\"$(XXT_VERSION)\"
ngtool_CFLAGS += -DNGTOOL_ID=\"ch.xxtou.ngtool\"
ngtool_CFLAGS += -I../shared/include/
ngtool_CFLAGS += -I../shared/
ngtool_CFLAGS += -I../app/
ngtool_CFLAGS += -IWrapper -I.
ngtool_CFLAGS += -include Wrapper/ngwrapper-prefix.pch
ngtool_CCFLAGS += -std=c++17 # <-- errors here
ifneq ($(DISABLE_SPECS),1)
ngtool_CFLAGS += -I../specs/
ngtool_CFLAGS += -DSPECS_SERVER=1
else
ngtool_CFLAGS += -DDISABLE_SPECS
endif
ngtool_LDFLAGS += -L$(THEOS_OBJ_DIR)
ngtool_LDFLAGS += -FLibrary/ArgumentParser.xcframework/ios-arm64 -FLibrary/ArgumentParser.xcframework/ios-arm64_armv7 -framework ArgumentParser
ngtool_LDFLAGS += -FLibrary/ArgumentParserToolInfo.xcframework/ios-arm64 -FLibrary/ArgumentParserToolInfo.xcframework/ios-arm64_armv7 -framework ArgumentParserToolInfo
ngtool_LDFLAGS += -FLibrary/Logging.xcframework/ios-arm64 -FLibrary/Logging.xcframework/ios-arm64_armv7 -framework Logging
ngtool_LDFLAGS += -FLibrary/SQLite.xcframework/ios-arm64 -FLibrary/SQLite.xcframework/ios-arm64_armv7 -framework SQLite
# ngtool_LDFLAGS += "-Wl,-rpath,/Library/Frameworks"
ngtool_LIBRARIES += tfcontainermanager
ngtool_WEAK_LIBRARIES += Library/CoreUI.tbd
ifneq ($(DISABLE_SPECS),1)
ngtool_LIBRARIES += specsmanager
endif
# Use `swift-create-xcframework` tool to create xcframeworks here...
ngtool_SWIFTFLAGS += -FLibrary/ArgumentParser.xcframework/ios-arm64 -FLibrary/ArgumentParser.xcframework/ios-arm64_armv7 -framework ArgumentParser
ngtool_SWIFTFLAGS += -FLibrary/ArgumentParserToolInfo.xcframework/ios-arm64 -FLibrary/ArgumentParserToolInfo.xcframework/ios-arm64_armv7 -framework ArgumentParserToolInfo
ngtool_SWIFTFLAGS += -FLibrary/Logging.xcframework/ios-arm64 -FLibrary/Logging.xcframework/ios-arm64_armv7 -framework Logging
ngtool_SWIFTFLAGS += -FLibrary/SQLite.xcframework/ios-arm64 -FLibrary/SQLite.xcframework/ios-arm64_armv7 -framework SQLite
ngtool_SWIFTFLAGS += -import-objc-header Wrapper/Wrapper+Bridging.h
ifeq ($(TARGET_CODESIGN),ldid)
ngtool_CODESIGN_FLAGS += -Sent.plist
else
ngtool_CODESIGN_FLAGS += --entitlements ent.plist $(TARGET_CODESIGN_FLAGS)
endif
ngtool_INSTALL_PATH += /usr/local/example/bin
include $(THEOS_MAKE_PATH)/tool.mk
before-all::
@ln -sfn ../../app/TFContainerManager.h Wrapper/TFContainerManager.h
@ln -sfn ../../specs/SpecsManager.h Wrapper/SpecsManager.h
@ln -sfn ../../specs/YAMLSerialization.h Wrapper/YAMLSerialization.h
after-all::
@ldid -Sent.plist $(THEOS_OBJ_DIR)/ngtool |
If I changed to this (split into two targets), such errors went away. ARCHS := arm64
TARGET := iphone:clang:15.5:13.0
include $(THEOS)/makefiles/common.mk
LIBRARY_NAME := libngwrapper
libngwrapper_FILES += $(wildcard Wrapper/*.m) # <- you're right, *_CCFLAGS won't apply to objc sources
libngwrapper_FILES += $(wildcard Wrapper/*.mm)
libngwrapper_FILES += ../shared/TFLuaBridge+Shell.mm
libngwrapper_CFLAGS += -fobjc-arc
libngwrapper_CFLAGS += -fvisibility=hidden
libngwrapper_CFLAGS += -DXXT_VERSION=\"$(XXT_VERSION)\"
libngwrapper_CFLAGS += -DNGTOOL_ID=\"ch.xxtou.ngtool\"
libngwrapper_CFLAGS += -I../shared/include/
libngwrapper_CFLAGS += -I../shared/
libngwrapper_CFLAGS += -I../app/
libngwrapper_CFLAGS += -IWrapper -I.
libngwrapper_CFLAGS += -include Wrapper/ngwrapper-prefix.pch
ifneq ($(DISABLE_SPECS),1)
libngwrapper_CFLAGS += -I../specs/
libngwrapper_CFLAGS += -DSPECS_SERVER=1
else
libngwrapper_CFLAGS += -DDISABLE_SPECS
endif
libngwrapper_CCFLAGS += -std=gnu++17
libngwrapper_LDFLAGS += -ObjC
libngwrapper_LINKAGE_TYPE := static
libngwrapper_INSTALL := 0
include $(THEOS_MAKE_PATH)/library.mk
TOOL_NAME := ngtool
ngtool_FILES += Entry.swift
ngtool_FILES += $(wildcard Commands/*.swift)
ngtool_FILES += $(wildcard Errors/*.swift)
ngtool_FILES += $(wildcard Extensions/*.swift)
ngtool_FILES += $(wildcard Library/*.swift)
ngtool_FILES += $(wildcard Models/*.swift)
ngtool_FILES += $(wildcard SwiftWrapper/*.swift)
ngtool_LDFLAGS += -L$(THEOS_OBJ_DIR)
ngtool_LDFLAGS += -FLibrary/ArgumentParser.xcframework/ios-arm64 -FLibrary/ArgumentParser.xcframework/ios-arm64_armv7 -framework ArgumentParser
ngtool_LDFLAGS += -FLibrary/ArgumentParserToolInfo.xcframework/ios-arm64 -FLibrary/ArgumentParserToolInfo.xcframework/ios-arm64_armv7 -framework ArgumentParserToolInfo
ngtool_LDFLAGS += -FLibrary/Logging.xcframework/ios-arm64 -FLibrary/Logging.xcframework/ios-arm64_armv7 -framework Logging
ngtool_LDFLAGS += -FLibrary/SQLite.xcframework/ios-arm64 -FLibrary/SQLite.xcframework/ios-arm64_armv7 -framework SQLite
# ngtool_LDFLAGS += "-Wl,-rpath,/Library/Frameworks"
ngtool_LIBRARIES += ngwrapper
ngtool_LIBRARIES += tfcontainermanager
ngtool_WEAK_LIBRARIES += Library/CoreUI.tbd
ifneq ($(DISABLE_SPECS),1)
ngtool_LIBRARIES += specsmanager
endif
# Use `swift-create-xcframework` tool to create xcframeworks here...
ngtool_SWIFTFLAGS += -FLibrary/ArgumentParser.xcframework/ios-arm64 -FLibrary/ArgumentParser.xcframework/ios-arm64_armv7 -framework ArgumentParser
ngtool_SWIFTFLAGS += -FLibrary/ArgumentParserToolInfo.xcframework/ios-arm64 -FLibrary/ArgumentParserToolInfo.xcframework/ios-arm64_armv7 -framework ArgumentParserToolInfo
ngtool_SWIFTFLAGS += -FLibrary/Logging.xcframework/ios-arm64 -FLibrary/Logging.xcframework/ios-arm64_armv7 -framework Logging
ngtool_SWIFTFLAGS += -FLibrary/SQLite.xcframework/ios-arm64 -FLibrary/SQLite.xcframework/ios-arm64_armv7 -framework SQLite
ngtool_SWIFTFLAGS += -import-objc-header Wrapper/Wrapper+Bridging.h
ifeq ($(TARGET_CODESIGN),ldid)
ngtool_CODESIGN_FLAGS += -Sent.plist
else
ngtool_CODESIGN_FLAGS += --entitlements ent.plist $(TARGET_CODESIGN_FLAGS)
endif
ngtool_INSTALL_PATH += /usr/local/example/bin
include $(THEOS_MAKE_PATH)/tool.mk
before-all::
@ln -sfn ../../app/TFContainerManager.h Wrapper/TFContainerManager.h
@ln -sfn ../../specs/SpecsManager.h Wrapper/SpecsManager.h
@ln -sfn ../../specs/YAMLSerialization.h Wrapper/YAMLSerialization.h
after-all::
@ldid -Sent.plist $(THEOS_OBJ_DIR)/ngtool |
IMPORTANT: To replicate this problem, you need Xcode 13.2.1 or earlier versions. |
I'm still not able to reproduce. Environment: $ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
$ xcrun -f make
/Users/leptos/Downloads/Xcode.app/Contents/Developer/usr/bin/make
$ clang++ --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Users/leptos/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ swift --version
swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Target: arm64-apple-macosx13.0
$ plutil -extract CFBundleShortVersionString raw ~/Downloads/Xcode.app/Contents/Info.plist
13.2.1 Makefile: TARGET := iphone:clang:15.2:13.0
SYSROOT := /Users/leptos/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk
include $(THEOS)/makefiles/common.mk
LIBRARY_NAME = T
T_FILES = main.m help.swift core.mm
T_CFLAGS = -fobjc-arc
T_CCFLAGS = -std=c++17
T_INSTALL_PATH = /usr/local/lib
include $(THEOS_MAKE_PATH)/library.mk Edit: Updated with Swift usage |
I have reviewed theos' usage of |
@leptos-null I believe that this is a theos issue. it is very easy replicable on the latest version of Xcode v14.3.1. To replicate, follow this project structure: Compile normally, check generated header file -> No class definition for the class we exposed to objective c. On top of that, lets add
Issues: I can attest that this was working fine, I believe it might be due to theos. I have not had the time to debug this issue |
Recently I have had the same error. I updated Xcode, but there is new error: generate-pch command failed with exit code 1 (use -v to see invocation) Theos does not compile my project with Swift while there is -std=c++14 flag in my_project_CCFLAGS |
Thanks @HearseDev. I was able to reproduce with the steps you provided. This was the minimum project with which I was able to reproduce. Adding to help with future debugging. |
I can debug later today and provide more information since this issue is kind of a big deal which prohibits objc+swift projects from being compiled. |
@HearseDev please open a separate issue for this if it persists even with the latest theos. |
Oops, seems like this issue has been fixed within latest theos. |
Providing logs in here for more context, running HelloWorld project from the provided HelloWorld.zip:
With messages: make clean all messages=yes
|
@leptos-null @L1ghtmann replicates the one of the errors we are experiencing
|
Thank you. This is the bug. Per
|
@L1ghtmann @leptos-null Fixed issue, it compiles the Helper file just fine. Line 183 makefiles/instance/rules.mk
to
|
I am not sure how correct the solution is, but if this is the actual solution, perhaps we should also remove OBJCCFLAGS as well? |
@leptos-null @L1ghtmann make clean all
|
What problem are you trying to solve?
Create an
iphone/application
project, add a C++ file with any C++17 feature and inside the Makfile set theproject_CXXFLAGS
orCXXFLAGS
to-std=c++17
.At the moment this causes no effect on the project, at all. And setting that to
CCFLAGS
causeserror: invalid argument '-std=c++17' not allowed with 'Objective-C'
.Describe the solution you’d like
Make the
project_CXXFLAGS
var properly apply to the project's C++ files.Describe any alternatives you’ve considered
Perhaps if theos shipped with a toolchain that contains a newer clang, instead of the current one which comes with clang-10 from a commit that dates back to october 2020.
Documentation, Adoption, Migration Strategy
No response
The text was updated successfully, but these errors were encountered: