theos icon indicating copy to clipboard operation
theos copied to clipboard

Add C++ makefile flags support.

Open IlannM opened this issue 2 years ago • 22 comments

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 the project_CXXFLAGS or CXXFLAGS to -std=c++17.
At the moment this causes no effect on the project, at all. And setting that to CCFLAGS causes error: 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

IlannM avatar Jul 13 '23 20:07 IlannM

Agree with this enhancement. CCFLAGS sometimes applies to C/C++/Objective-C/Objective-C++/Swift. But we need CXXFLAGS, which applies to C++/Objective-C++ only when we use -std= flag with older clang (Xcode 13.2.1).

Screen Shot 2023-07-26 at 11 27 13 PM

Lessica avatar Jul 26 '23 15:07 Lessica

@Lessica would you mind sharing your makefile? Myself and one other have attempted to replicate both your and Ilan's error and cannot. Thanks!

L1ghtmann avatar Jul 27 '23 23:07 L1ghtmann

@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 cpptarget and specify cpptarget_CCFLAGS= -std=c++17 flag only for that target. Then I made a link between them.

Lessica avatar Jul 28 '23 01:07 Lessica

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 https://github.com/theos/theos/blob/697afd9ffc67d34756bfc5193c58a615cb90a16b/makefiles/instance/rules.mk#L276

If you wouldn't mind, it may help to see the full makefile

L1ghtmann avatar Jul 28 '23 01:07 L1ghtmann

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

https://github.com/theos/theos/blob/697afd9ffc67d34756bfc5193c58a615cb90a16b/makefiles/instance/rules.mk#L276

If you wouldn't mind, it may help to see the full makefile

See ALL_SWIFTFLAGS.
I have Swift sources in my project Makefile. I think it is because XXX_CCFLAGS were passed to -Xcc in Swift targets.

Lessica avatar Jul 28 '23 01:07 Lessica

To replicate this problem, you need Xcode 13.2.1 or earlier versions. Here is my Makefile:

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

Lessica avatar Jul 28 '23 02:07 Lessica

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

Lessica avatar Jul 28 '23 02:07 Lessica

IMPORTANT: To replicate this problem, you need Xcode 13.2.1 or earlier versions.

Lessica avatar Jul 28 '23 02:07 Lessica

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

leptos-null avatar Jul 30 '23 20:07 leptos-null

I have reviewed theos' usage of CCFLAGS and I do not see any misusage: CCFLAGS is only applied to c++ and objective-c++ code. Without being able to reproduce and that Lessica has indicated this only happens with older version of Xcode, I believe this is not a theos issue.

leptos-null avatar Jul 30 '23 21:07 leptos-null

@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: Tweak.xm with hook Helper.swift with a class using @objc

Compile normally, check generated header file -> No class definition for the class we exposed to objective c.

On top of that, lets add $(TWEAK_NAME)_CCFLAGS = -std=c++2b to our makefile Result:

make clean all
==> Cleaning…
> Making all for tweak Test…
==> Preprocessing Tweak.xm…
==> Preprocessing Tweak.xm…
==> Compiling module interface (arm64e)…
==> Compiling module interface (arm64)…
error: emit-module command failed with exit code 1 (use -v to see invocation)
error: emit-module command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: invalid argument '-std=c++2b' not allowed with 'Objective-C'
<unknown>:0: error: clang importer creation failed

<unknown>:0: error: invalid argument '-std=c++2b' not allowed with 'Objective-C'
<unknown>:0: error: clang importer creation failed

Issues: Issue with CCFlags when compiling swift files Improper swift generated header

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

HearseDev avatar Aug 25 '23 04:08 HearseDev

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

retr0devops avatar Aug 25 '23 09:08 retr0devops

Thanks @HearseDev. I was able to reproduce with the steps you provided.

HelloWorld.zip

This was the minimum project with which I was able to reproduce. Adding to help with future debugging.

leptos-null avatar Aug 26 '23 23:08 leptos-null

Thanks @HearseDev. I was able to reproduce with the steps you provided.

HelloWorld.zip

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 avatar Aug 26 '23 23:08 HearseDev

Compile normally, check generated header file -> No class definition for the class we exposed to objective c.

@HearseDev please open a separate issue for this if it persists even with the latest theos.

L1ghtmann avatar Aug 26 '23 23:08 L1ghtmann

Compile normally, check generated header file -> No class definition for the class we exposed to objective c.

@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.

HearseDev avatar Aug 26 '23 23:08 HearseDev

Thanks @HearseDev. I was able to reproduce with the steps you provided.

HelloWorld.zip

This was the minimum project with which I was able to reproduce. Adding to help with future debugging.

Providing logs in here for more context, running HelloWorld project from the provided HelloWorld.zip: make clean all

==> Cleaning…
> Making all for tweak HelloWorld…
==> Preprocessing Tweak.xm…
==> Preprocessing Tweak.xm…
==> Compiling module interface (arm64)…
==> Compiling module interface (arm64e)…
error: emit-module command failed with exit code 1 (use -v to see invocation)
error: emit-module command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: invalid argument '-std=c++17' not allowed with 'Objective-C'
<unknown>:0: error: clang importer creation failed

<unknown>:0: error: invalid argument '-std=c++17' not allowed with 'Objective-C'
<unknown>:0: error: clang importer creation failed

make[4]: *** [/Users/dev/.theos/makefiles/instance/rules.mk:350: internal-swift-HelloWorld-arm64] Error 1
make[4]: *** [/Users/dev/.theos/makefiles/instance/rules.mk:350: internal-swift-HelloWorld-arm64e] Error 1
make[3]: *** [/Users/dev/.theos/makefiles/instance/rules.mk:359: /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/.swift-stamp] Error 2
make[3]: *** [/Users/dev/.theos/makefiles/instance/rules.mk:359: /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/.swift-stamp] Error 2
rm /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/Tweak.xm.mm
rm /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/Tweak.xm.mm
make[2]: *** [/Users/dev/.theos/makefiles/instance/library.mk:52: /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/HelloWorld.dylib] Error 2
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [/Users/dev/.theos/makefiles/instance/library.mk:52: /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/HelloWorld.dylib] Error 2
make[1]: *** [/Users/dev/.theos/makefiles/instance/library.mk:37: internal-library-all_] Error 2
make: *** [/Users/dev/.theos/makefiles/master/rules.mk:146: HelloWorld.all.tweak.variables] Error 2

With messages: make clean all messages=yes

(printf "\e[0;3%im==> \e[1;39m%s…\e[m\n" 6 "Cleaning"); set -o pipefail; (rm -rf "/Users/dev/Downloads/HelloWorld/.theos/obj")
==> Cleaning…
set -o pipefail; (rm "/Users/dev/Downloads/HelloWorld/.theos/build_session")
set -o pipefail; (touch "/Users/dev/Downloads/HelloWorld/.theos/build_session")
set -o pipefail; (rm -rf "/Users/dev/Downloads/HelloWorld/.theos/_" "/Users/dev/Downloads/HelloWorld/.theos/swift" "/Users/dev/Downloads/HelloWorld/.theos/compile_commands.json.tmp")
set -o pipefail; (rm -rf /Users/dev/Downloads/HelloWorld/.theos/swift)
set -o pipefail; (mkdir -p /Users/dev/Downloads/HelloWorld/.theos/swift /Users/dev/Downloads/HelloWorld/.theos/swift/markers)
> Making all for tweak HelloWorld…
set -o pipefail; (if mkdir /Users/dev/Downloads/HelloWorld/.theos/swift/markers/swift_support 2>/dev/null; then \
	make -f Makefile --no-keep-going COLOR=1 internal-HelloWorld-swift-support THEOS_START_SWIFT_SUPPORT=1 || exit $?; \
else :; \
fi)
make[2]: Entering directory '/Users/dev/Downloads/HelloWorld'
set -o pipefail; (/Users/dev/.theos/bin/swift-bootstrapper.pl swift /Users/dev/.theos/vendor/swift-support 'printf "\e[0;3%im==> \e[1;39m%s…\e[m\n" 4 "Building Swift support tools"' >&2)
set -o pipefail; (rm -f /Users/dev/Downloads/HelloWorld/.theos/swift/output.lock)
set -o pipefail; (touch /Users/dev/Downloads/HelloWorld/.theos/swift/output.lock)
make[2]: Leaving directory '/Users/dev/Downloads/HelloWorld'
make -f Makefile --no-keep-going COLOR=1 \
	internal-library-compile \
	_THEOS_CURRENT_TYPE=tweak THEOS_CURRENT_INSTANCE=HelloWorld _THEOS_CURRENT_OPERATION=compile \
	THEOS_BUILD_DIR="." _THEOS_MAKE_PARALLEL=yes
make -f Makefile --no-print-directory --no-keep-going internal-tweak-compile _THEOS_CURRENT_TYPE="tweak" THEOS_CURRENT_INSTANCE="HelloWorld" _THEOS_CURRENT_OPERATION="compile" THEOS_BUILD_DIR="." THEOS_CURRENT_ARCH="arm64"
make -f Makefile --no-print-directory --no-keep-going internal-tweak-compile _THEOS_CURRENT_TYPE="tweak" THEOS_CURRENT_INSTANCE="HelloWorld" _THEOS_CURRENT_OPERATION="compile" THEOS_BUILD_DIR="." THEOS_CURRENT_ARCH="arm64e"
set -o pipefail; (mkdir -p /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/)
set -o pipefail; (/Users/dev/.theos/vendor/swift-support/.theos_build/release/generate-output-file-map /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64 bfda77bf Helper.swift > /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/output-file-map.bfda77bf.json)
set -o pipefail; (mkdir -p /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/)
set -o pipefail; (/Users/dev/.theos/vendor/swift-support/.theos_build/release/generate-output-file-map /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e a50a4b02 Helper.swift > /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/output-file-map.a50a4b02.json)
set -o pipefail; (rm -f /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/.swift-stamp.tmp)
set -o pipefail; (touch /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/.swift-stamp.tmp)
set -o pipefail; (mkdir -p /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/./ /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/generated/)
set -o pipefail; (make -f Makefile --no-print-directory --no-keep-going \
	internal-swift-HelloWorld-arm64e \
	THEOS_BUILD_SWIFT="1" \
	THEOS_CURRENT_INSTANCE="HelloWorld" \
	THEOS_BUILD_DIR="." \
	THEOS_CURRENT_ARCH="arm64e")
set -o pipefail; (rm -f /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/.swift-stamp.tmp)
set -o pipefail; (touch /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/.swift-stamp.tmp)
set -o pipefail; (mkdir -p /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/./ /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/generated/)
set -o pipefail; (make -f Makefile --no-print-directory --no-keep-going \
	internal-swift-HelloWorld-arm64 \
	THEOS_BUILD_SWIFT="1" \
	THEOS_CURRENT_INSTANCE="HelloWorld" \
	THEOS_BUILD_DIR="." \
	THEOS_CURRENT_ARCH="arm64")
set -o pipefail; (mkdir -p /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/)
(printf "\e[0;3%im==> \e[1;39m%s…\e[m\n" 1 "Preprocessing Tweak.xm"); set -o pipefail; (/Users/dev/.theos/bin/logos.pl -c warnings=error -c generator=MobileSubstrate    Tweak.xm > /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/Tweak.xm.mm)
==> Preprocessing Tweak.xm…
set -o pipefail; (mkdir -p /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/)
(printf "\e[0;3%im==> \e[1;39m%s…\e[m\n" 1 "Preprocessing Tweak.xm"); set -o pipefail; (/Users/dev/.theos/bin/logos.pl -c warnings=error -c generator=MobileSubstrate    Tweak.xm > /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/Tweak.xm.mm)
==> Preprocessing Tweak.xm…
set -o pipefail; (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -c -I/Users/dev/.theos/include/iphone -I/Users/dev/.theos/include -I/Users/dev/.theos/vendor/include -I/Users/dev/.theos/include/_fallback -Xfrontend -color-diagnostics -Xcc -fcolor-diagnostics -Xcc -DTARGET_IPHONE=1 -Xcc -O0 -Xcc -Wall -Xcc -ggdb -Xcc -Wno-unused-command-line-argument -Xcc -Qunused-arguments -Xcc -Werror -Xcc -D -Xcc THEOS_PACKAGE_INSTALL_PREFIX="\"\"" -Xcc -isysroot -Xcc "/Users/dev/.theos/sdks/iPhoneOS14.5.sdk/" -Xcc -target -Xcc arm64-apple-ios14.0 -Xcc -resource-dir -Xcc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/swift/clang -Xcc -fobjc-arc -Xcc -DDEBUG -Xcc -O0 -Xcc -DTHEOS_INSTANCE_NAME="\"HelloWorld\"" -Xcc -fmodules -Xcc -fcxx-modules -Xcc -fmodule-name=HelloWorld -Xcc -fbuild-session-file=/Users/dev/Downloads/HelloWorld/.theos/build_session -Xcc -fmodules-prune-after=345600 -Xcc -fmodules-prune-interval=86400 -Xcc -fmoduleset -o pipefail; (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -c -I/Users/dev/.theos/include/iphone -I/Users/dev/.theos/include -I/Users/dev/.theos/vendor/include -I/Users/dev/.theos/include/_fallback -Xfrontend -color-diagnostics -Xcc -fcolor-diagnostics -Xcc -DTARGET_IPHONE=1 -Xcc -O0 -Xcc -Wall -Xcc -ggdb -Xcc -Wno-unused-command-line-argument -Xcc -Qunused-arguments -Xcc -Werror -Xcc -D -Xcc THEOS_PACKAGE_INSTALL_PREFIX="\"\"" -Xcc -isysroot -Xcc "/Users/dev/.theos/sdks/iPhoneOS14.5.sdk/" -Xcc -target -Xcc arm64e-apple-ios14.0 -Xcc -resource-dir -Xcc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/swift/clang -Xcc -fobjc-arc -Xcc -DDEBUG -Xcc -O0 -Xcc -DTHEOS_INSTANCE_NAME="\"HelloWorld\"" -Xcc -fmodules -Xcc -fcxx-modules -Xcc -fmodule-name=HelloWorld -Xcc -fbuild-session-file=/Users/dev/Downloads/HelloWorld/.theos/build_session -Xcc -fmodules-prune-after=345600 -Xcc -fmodules-prune-interval=86400 -Xcc -fmodules-validate-once-per-build-session -Xcc -arch -Xcc arm64e -Xcc -stdlib=libc++ -Xcc -std=c++17 -Xcc -F/Users/dev/.theos/vendor/lib -Xcc -F/Users/dev/.theos/lib -Xcc -F/Users/dev/.theos/lib/iphone -Xcc -F/Users/dev/.theos/sdks/iPhoneOS14.5.sdk//System/Library/PrivateFrameworks -Xcc -F/Users/dev/.theos/vendor/lib/iphone/rootful -Xcc -F/Users/dev/.theos/lib/iphone/rootful -DTHEOS_SWIFT -DTARGET_IPHONE  -module-name HelloWorld -g -F/Users/dev/.theos/vendor/lib -F/Users/dev/.theos/lib -F/Users/dev/.theos/lib/iphone -F/Users/dev/.theos/sdks/iPhoneOS14.5.sdk//System/Library/PrivateFrameworks -F/Users/dev/.theos/vendor/lib/iphone/rootful -F/Users/dev/.theos/lib/iphone/rootful -swift-version 5 -parse-as-library -sdk "/Users/dev/.theos/sdks/iPhoneOS14.5.sdk/"  -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/swift   -DDEBUG -Onone -incremental -target arm64e-apple-ios14.0 -output-file-map /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/output-file-map.a50a4b02.json -emit-objc-header-path /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/generated/HelloWorld-Swift.h -emit-dependencies -emit-module-path /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/HelloWorld.swiftmodule -pch-output-dir /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/HelloWorld-pch Helper.swift -parseable-output 2>&1 \
| /Users/dev/.theos/vendor/swift-support/.theos_build/release/parse-swiftc-output 1 /Users/dev/Downloads/HelloWorld/.theos/swift/output.lock arm64e)
s-validate-once-per-build-session -Xcc -arch -Xcc arm64 -Xcc -stdlib=libc++ -Xcc -std=c++17 -Xcc -F/Users/dev/.theos/vendor/lib -Xcc -F/Users/dev/.theos/lib -Xcc -F/Users/dev/.theos/lib/iphone -Xcc -F/Users/dev/.theos/sdks/iPhoneOS14.5.sdk//System/Library/PrivateFrameworks -Xcc -F/Users/dev/.theos/vendor/lib/iphone/rootful -Xcc -F/Users/dev/.theos/lib/iphone/rootful -DTHEOS_SWIFT -DTARGET_IPHONE  -module-name HelloWorld -g -F/Users/dev/.theos/vendor/lib -F/Users/dev/.theos/lib -F/Users/dev/.theos/lib/iphone -F/Users/dev/.theos/sdks/iPhoneOS14.5.sdk//System/Library/PrivateFrameworks -F/Users/dev/.theos/vendor/lib/iphone/rootful -F/Users/dev/.theos/lib/iphone/rootful -swift-version 5 -parse-as-library -sdk "/Users/dev/.theos/sdks/iPhoneOS14.5.sdk/"  -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/swift   -DDEBUG -Onone -incremental -target arm64-apple-ios14.0 -output-file-map /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/output-file-map.bfda77bf.json -emit-objc-header-path /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/generated/HelloWorld-Swift.h -emit-dependencies -emit-module-path /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/HelloWorld.swiftmodule -pch-output-dir /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/HelloWorld-pch Helper.swift -parseable-output 2>&1 \
| /Users/dev/.theos/vendor/swift-support/.theos_build/release/parse-swiftc-output 1 /Users/dev/Downloads/HelloWorld/.theos/swift/output.lock arm64)
==> Compiling module interface (arm64)…
==> Compiling module interface (arm64e)…
error: emit-module command failed with exit code 1 (use -v to see invocation)
error: emit-module command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: invalid argument '-std=c++17' not allowed with 'Objective-C'
<unknown>:0: error: clang importer creation failed

<unknown>:0: error: invalid argument '-std=c++17' not allowed with 'Objective-C'
<unknown>:0: error: clang importer creation failed

make[4]: *** [/Users/dev/.theos/makefiles/instance/rules.mk:350: internal-swift-HelloWorld-arm64] Error 1
make[4]: *** [/Users/dev/.theos/makefiles/instance/rules.mk:350: internal-swift-HelloWorld-arm64e] Error 1
make[3]: *** [/Users/dev/.theos/makefiles/instance/rules.mk:359: /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/.swift-stamp] Error 2
make[3]: *** [/Users/dev/.theos/makefiles/instance/rules.mk:359: /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/.swift-stamp] Error 2
rm /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/Tweak.xm.mm
rm /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/Tweak.xm.mm
make[2]: *** [/Users/dev/.theos/makefiles/instance/library.mk:52: /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64e/HelloWorld.dylib] Error 2
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [/Users/dev/.theos/makefiles/instance/library.mk:52: /Users/dev/Downloads/HelloWorld/.theos/obj/debug/arm64/HelloWorld.dylib] Error 2
make[1]: *** [/Users/dev/.theos/makefiles/instance/library.mk:37: internal-library-all_] Error 2
make: *** [/Users/dev/.theos/makefiles/master/rules.mk:146: HelloWorld.all.tweak.variables] Error 2

HearseDev avatar Aug 27 '23 00:08 HearseDev

@leptos-null @L1ghtmann You can see in the verbose logs, that -Xcc $(CC_FLAGS) is being passed into swiftc

replicates the one of the errors we are experiencing

swiftc -Xcc -std=c++17 Helper.swift
<unknown>:0: error: invalid argument '-std=c++17' not allowed with 'Objective-C'
<unknown>:0: error: clang importer creation failed

HearseDev avatar Aug 27 '23 00:08 HearseDev

Thank you. This is the bug. Per swiftc:

  -Xcc <arg>              Pass <arg> to the C/C++/Objective-C compiler

leptos-null avatar Aug 27 '23 00:08 leptos-null

@L1ghtmann @leptos-null Fixed issue, it compiles the Helper file just fine. Line 183 makefiles/instance/rules.mk

ALL_SWIFTFLAGS = $(_THEOS_INTERNAL_SWIFTCOLORFLAGS) $(foreach flag,$(ALL_CFLAGS) $(ALL_CCFLAGS) $(ALL_OBJCFLAGS) $(ALL_OBJCCFLAGS),-Xcc $(flag)) $(_THEOS_INTERNAL_SWIFTFLAGS) $(_THEOS_TARGET_SWIFTFLAGS) $(ADDITIONAL_SWIFTFLAGS) $(call __schema_var_all,$(THEOS_CURRENT_INSTANCE)_,SWIFTFLAGS) $(call __schema_var_all,,SWIFTFLAGS)

to

ALL_SWIFTFLAGS = $(_THEOS_INTERNAL_SWIFTCOLORFLAGS) $(foreach flag,$(ALL_CFLAGS) $(ALL_OBJCFLAGS) $(ALL_OBJCCFLAGS),-Xcc $(flag)) $(_THEOS_INTERNAL_SWIFTFLAGS) $(_THEOS_TARGET_SWIFTFLAGS) $(ADDITIONAL_SWIFTFLAGS) $(call __schema_var_all,$(THEOS_CURRENT_INSTANCE)_,SWIFTFLAGS) $(call __schema_var_all,,SWIFTFLAGS)

HearseDev avatar Aug 27 '23 00:08 HearseDev

I am not sure how correct the solution is, but if this is the actual solution, perhaps we should also remove OBJCCFLAGS as well?

HearseDev avatar Aug 27 '23 00:08 HearseDev

@leptos-null @L1ghtmann Removing both CCFLAGS OBJCCFLAGS, I will leave this here. Also I can now compile my bigger projects that were having issues because of this. If you guys can agree on this solution, I can send over the PR right away.

make clean all

==> Cleaning…
> Making all for tweak HelloWorld…
==> Preprocessing Tweak.xm…
==> Preprocessing Tweak.xm…
==> Compiling module interface (arm64)…
==> Compiling module interface (arm64e)…
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: remark: unable to perform implicit import of "_StringProcessing" module: no such module found

<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: remark: unable to perform implicit import of "_StringProcessing" module: no such module found

==> Compiling Helper.swift (arm64)…
==> Compiling Helper.swift (arm64e)…
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: remark: unable to perform implicit import of "_StringProcessing" module: no such module found

<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: remark: unable to perform implicit import of "_StringProcessing" module: no such module found

==> Compiling Tweak.xm (arm64e)…
==> Compiling Tweak.xm (arm64)…
==> Linking tweak HelloWorld (arm64e)…
==> Generating debug symbols for HelloWorld…
==> Linking tweak HelloWorld (arm64)…
==> Generating debug symbols for HelloWorld…
==> Merging tweak HelloWorld…
==> Signing HelloWorld…

HearseDev avatar Aug 27 '23 00:08 HearseDev