open-obfuscator / o-mvll

:electron: O-MVLL is a LLVM-based obfuscator for native code (Android & iOS)
https://obfuscator.re/omvll
Apache License 2.0
617 stars 66 forks source link

Latest plugin build fails on OSX #55

Open cutecatsandvirtualmachines opened 2 months ago

cutecatsandvirtualmachines commented 2 months ago

Description

Plugin build on OSX will fail using llvm@16 installed from brew.

One instance of the error can be found here: https://github.com/open-obfuscator/o-mvll/blob/6f7aaf3c15e54dfeca24206f1b0edbdd9a0ae360/src/core/utils.cpp#L34

Where ninja will complain about: error: use of undeclared identifier 'Optional'

Changing all #if LLVM_VERSION_MAJOR > 16 to #if LLVM_VERSION_MAJOR >= 16 in utils.cpp and Arithmetic.cpp fixes the issue.

How to reproduce the issue

Build as described in the documentation, passing llvm@16 path installed from brew instead of cloned llvm from apple.

antoniofrighetto commented 2 months ago

Thanks for the report. o-mvll is not meant to be built with other LLVM distributions but with our pre-built package. If you want to build o-mvll yourself, please find the LLVM dependencies here, as per documentation here.

cutecatsandvirtualmachines commented 2 months ago

Is the llvm dependency available somewhere as source?

marcobrador commented 2 months ago

Hi @cutecatsandvirtualmachines ,

Thanks for your input.

Right now our top priority is to make o-mvll compatible with the official distributions (Xcode and Android NDK) used by Android / iOS developers. Since Apple Clang is not exactly the same as upstream LLVM, there's no guarantee the plugin will work with it (actually, there's no guarantee the plugin will work with any other clang other than the ones our CI builds against).

The Apple Clang dependency right now is distributed only in binary format.

Having said that, building the plugin against upstream LLVM should not be too complicated. If you want to create a PR for this, we would then evaluate the possibility of shipping a "vanilla" version of the plugin built against upstream LLVM on each release.

BR, Marc

weliveindetail commented 1 month ago

@cutecatsandvirtualmachines In terms of upstream compatibility, the current #if LLVM_VERSION_MAJOR > 16 implementation looks correct. The llvm::Optional legacy alias is removed only after release 16: https://github.com/llvm/llvm-project/blob/release/16.x/llvm/include/llvm/ADT/Optional.h#L23-L24

I assume brew still ships this header? Maybe the difference is that upstream LLVM doesn't have a transitive include path for it anymore? Can you try this and send a PR if that fixes the issue?

#if LLVM_VERSION_MAJOR <= 16
#include <llvm/ADT/Optional.h>
#endif