obfuscator-llvm / obfuscator

3.88k stars 1.17k forks source link

Xcode plugin/obfuscator stopped working under Xcode 10 (10A255) #130

Open pawelkijowskizimperium opened 5 years ago

pawelkijowskizimperium commented 5 years ago

Since upgrading to Xcode 10 (10A255) I am getting the following errors:

2018-09-18 08:42:15.459 XCBBuildService21538:32188565 /Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/pLLVM.xcplugin/Contents/Resources/pLLVM 4.0.0.xcspec: error: unable to declare macro for option 'LLVM_LTO': conflictingMacroDeclarationType(previousType: XCBCore.MacroType.string, name: "LLVM_LTO") (while parsing 'com.apple.compilers.pllvm.4_0_0') 2018-09-18 08:42:15.461 XCBBuildService21538:32188565 /Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/pLLVM.xcplugin/Contents/Resources/pLLVM 4.0.0.xcspec: error: unable to declare macro for option 'CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK': conflictingMacroDeclarationType(previousType: XCBCore.MacroType.string, name: "CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK") (while parsing 'com.apple.compilers.pllvm.4_0_0')

If I modify my "pLLVM 4.0.0.xcspec" file and remove dup macros the Xcode Build System complains about -fla flag. It seems that the custom LLVM plugin is not installed correctly.

Is anybody else facing a similar problem? Any idea how to fix this?

Naville commented 5 years ago

From Xcode9 onwards you can just do make install-xcode-toolchain and none of the Plugin hassle

pawelkijowskizimperium commented 5 years ago

Thanks @Naville. That seemed to work, but now I am facing another issue. clang: error: -mllvm is not supported with -fembed-bitcode

Doesn't obfuscator-llvm support bitcode?

pawelkijowskizimperium commented 5 years ago

@Naville do you know how do I revert 'make install xcode-toolchain' ?

Naville commented 5 years ago

@pawelkijowskizimperium Just remove the whole directory

Naville commented 5 years ago

Usually /Library/Developer/Toolchains/LLVM.toolchain, if not, try ~/Library/Developer/Toolchains/LLVM.toolchain

Naville commented 5 years ago

Bitcode will never work with third party LLVM since Apple diverged the Bitcode format so even if you did generate one with bitcode embedded, AppStore will reject it.

pawelkijowskizimperium commented 5 years ago

@Naville Thank you!

marcobrador commented 5 years ago

@Naville , thanks for the info! Do you by any chance have any information about what did Apple modify in the bitcode when compared to Open Source LLVM?

mikeCalvir commented 5 years ago

Hi guys, I have just downloaded and built this project, and was about to do the Xcode plugin steps in the Installation Wiki page when I noticed your comments here.

So I have run "make install xcode-toolchain" in the build/tools folder, but now I have to admit I am a bit lost - do I need to still follow at least the last part of the plugin commands in order to get the o-llvm compiler to show up in the options and use it, or is there a different approach I should use now?

Thanks for any help, and apologies in advance if I am missing some obvious step - I'm new to code obfuscation and Xcode plugins actually, despite basically living within Xcode on and off for the last decade :)

Naville commented 5 years ago

@mikeCalvir Nah. As long as you are using Xcode 8+ , installing toolchain alone is enough to get things rolling

EDIT: Typo

mikeCalvir commented 5 years ago

@mikeCalvir Nah. As long as you are using Xcode 8+ , installing toolchain alone is enough to get things rolling

Thanks Naville. However, it's the "get things rolling" where I am stuck :)

I am using the latest-everything I believe (ie MacOS 10.14.1, Xcode 10.1 (10B61)).

Do I need to still follow at least the last part of the plugin commands in order to get the o-llvm compiler to show up in the options and use it, or is there a different approach I should use now?

Naville commented 5 years ago

@mikeCalvir If everything works as planned, merely make install-xcode-toolchain is more than enough. Take a look at my OLLVM's fork's installation guide (which you should totally switch to, by the way)

On the other hand, there are indeed some reports says the install-xcode-toolchain part stopped working after upgrading from Xcode9-ish to Xcode 10. However I was never able to locally reproduce that plus the reports says as long as they repeat the process again the problem vanishes.

EDIT: Here is a screenshot of my fork working under Xcode 10:

d0f06c0c-18a6-4c8b-a4a1-e8754417d0ce

PhoebusXS commented 5 years ago

Bitcode will never work with third party LLVM since Apple diverged the Bitcode format so even if you did generate one with bitcode embedded, AppStore will reject it.

Since when? My Xcode 8 project used to build with these two options. But it stopped working and gives this error in Xcode 10... Is there anything to do about it? error is: /clang:-1: -mllvm is not supported with -fembed-bitcode

PhoebusXS commented 5 years ago

Thanks @Naville. That seemed to work, but now I am facing another issue. clang: error: -mllvm is not supported with -fembed-bitcode

Doesn't obfuscator-llvm support bitcode?

Hi, have you had any progress on this error?

Naville commented 5 years ago

@PhoebusXS Since quite a while ago, which makes Bitcode pretty useless with Obfuscators unless someone decides to add compatibility with Apple Bitcode. Not very different, but still.

w.r.t to your second question. There are a few solutions to this that I can come up right now, however, these are far from easy and definitely not hassle-free. Again, this is basically pointless IMHO

Naville commented 5 years ago

@PhoebusXS Although, on my local LLVM7, this works fine.

~/Library/Developer/Toolchains/Hikari.xctoolchain/usr/bin/clang++ 123.mm -mllvm -enable-bcfobf -fembed-bitcode -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -fobjc-arc -c

In file included from 123.mm:1:
./123.h:3:12: warning: class 'AAA' defined without specifying a base class [-Wobjc-root-class]
@interface AAA
           ^
./123.h:3:15: note: add a super class to fix this problem
@interface AAA
              ^
               : NSObject 
1 warning generated.

naville @ navilledeMacBook-Pro in /tmp 
λ : >>> otool -s __LLVM __bitcode 123.o|head -n 10
123.o:
Contents of (__LLVM,__bitcode) section
0000000000002420    de c0 17 0b 00 00 00 00 14 00 00 00 d0 d5 00 00 
0000000000002430    07 00 00 01 42 43 c0 de 35 14 00 00 05 00 00 00 
0000000000002440    62 0c 30 24 49 59 be e6 ee d3 3e 2d 44 01 32 05 
0000000000002450    00 00 00 00 21 0c 00 00 85 27 00 00 0b 02 21 00 
0000000000002460    02 00 00 00 13 00 00 00 07 81 23 91 41 c8 04 49 
0000000000002470    06 10 32 39 92 01 84 0c 25 05 08 19 1e 04 8b 62 
0000000000002480    80 20 45 02 42 92 0b 42 04 11 32 14 38 08 18 4b 
0000000000002490    0a 32 82 88 48 90 14 20 43 46 88 a5 00 19 32 42 
PhoebusXS commented 5 years ago

@PhoebusXS Since quite a while ago, which makes Bitcode pretty useless with Obfuscators unless someone decides to add compatibility with Apple Bitcode. Not very different, but still.

w.r.t to your second question. There are a few solutions to this that I can come up right now, however, these are far from easy and definitely not hassle-free. Again, this is basically pointless IMHO

Thx for the answers.

Naville commented 5 years ago

@PhoebusXS I've Built BitCode support here https://github.com/HikariObfuscator/NatsukoiHanabi

PhoebusXS commented 5 years ago

@PhoebusXS I've Built BitCode support here https://github.com/HikariObfuscator/NatsukoiHanabi

Wow, great job! Will test it out soon. Working on some messy restructuring recently : (