DeClang icon indicating copy to clipboard operation
DeClang copied to clipboard

DeClang not applied to Unity macOS IL2CPP

Open cburiame opened this issue 9 months ago • 9 comments

Environment:

  • Unity 2022.3.21f1
    • Target Platform macOS
    • Scripting Backend IL2CPP
  • Xcode 15.2

Not DeClang but default clang is still used after setup.

Cmdline: "/Applications/Xcode15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" ...

It seems there is no --tool-chain-path on il2cpp option and may have no effect.

$ ./Il2CppOutputProject/IL2CPP/build/deploy/il2cpp --help

Options:
...

Is there any way to apply DeClang on Unity IL2CPP?

cburiame avatar May 07 '24 15:05 cburiame

The “--tool-chain-path” option is a hidden option, so it is not shown with the “--help” option. When building on the target MacOS with Unity, make sure to export xcode project. Once the xcode project is generated, are you running DeClang's xcode_setup command for all .xcodeproj directories? Then open the main .xcodeproj file using Xcode.app and build it, and DeClang should be running.

funa-tk avatar May 07 '24 16:05 funa-tk

Yes, I did for the all .xcodeproj directories. It seems DeClang is used on the main .xcodeproj, however default clang is still used on the GameAssembly .xcodeproj. I wonder what makes the difference.

cburiame avatar May 07 '24 18:05 cburiame

Upon investigation, I found that --tool-chain-path is not available when the target is MacOS. It is available when the target is iPhone. As a workaround, I think it works if you temporarily make “/Applications/Xcode15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++” a symbolic link to “/yourhome/.DeClang/compiler/usr/bin/clang++”.

With the current specification of the il2cpp command, it seems difficult to fix.

funa-tk avatar May 08 '24 06:05 funa-tk

I see. Would it be enough just replacing default clang/clang++ binary and no other setting modifications? (xcode_setup and binary replace?)

cburiame avatar May 08 '24 09:05 cburiame

Simply make /Applications/Xcode15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang a symbolic link to /YourHome/.DeClang/compiler/bin/clang. /Applications/Xcode15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ is already a symbolic link to the "clang" in same directory, so there is no need to change it. /YourHome/.DeClang/log.txt is the execution log of DeClang. It may be helpful. Use xcode_setup as usual. No other binary replacements are required.

funa-tk avatar May 08 '24 14:05 funa-tk

Thanks. By the way, how compatible is DeClang with Xcode Apple clang? Could there be any compatibility issues?

cburiame avatar May 08 '24 18:05 cburiame

DeClang is developed based on the official apple clang project, so there are no differences.

funa-tk avatar May 09 '24 02:05 funa-tk

My understanding is that Apple clang is closed source, so it should be different from that.

cburiame avatar May 09 '24 18:05 cburiame

Another question. Considering the balance between strength and performance, what would be an appropriate value for the overall_obfuscation (default 0) and split_level (default 1)?

cburiame avatar May 09 '24 18:05 cburiame

Control the strength of obfuscation with the split_level parameter. As the value of the split_level parameter is increased, the size of the function is also increased, and the function size is approximately [split_level+1] times larger. The setting value is case by case depending on the size of function and the importance of function, so you should find a good value yourself. The overall_obfuscation parameter is just a little something extra obfuscation, so do not expect good result.

funa-tk avatar May 10 '24 15:05 funa-tk