HikariObfuscator / Hikari

LLVM Obfuscator
1.93k stars 549 forks source link

Compile Error on macOS Catalina #88

Closed chachako closed 4 years ago

chachako commented 4 years ago

macOS 10.15.4 Xcode 11.4

运行wiki 安装教程后报错:

CMake Error at cmake/modules/CheckAtomic.cmake:53 (message): Host compiler appears to require libatomic, but cannot find it. Call Stack (most recent call first): cmake/config-ix.cmake:329 (include) CMakeLists.txt:590 (include)

-- Configuring incomplete, errors occurred! See also "/Users/dracula/Documents/Develop/Obfuscator/Build/CMakeFiles/CMakeOutput.log". See also "/Users/dracula/Documents/Develop/Obfuscator/Build/CMakeFiles/CMakeError.log".

CMakeError.log

chachako commented 4 years ago

Sorry, solved, reference: 1.https://blog.csdn.net/qq_32108329/article/details/104507251?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

2.https://github.com/Homebrew/homebrew-core/issues/20791

chachako commented 4 years ago

when execute the ninja, threw the following error:

ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) [95/2253] Building CXX object projects...iles/RTfuzzer.osx.dir/FuzzerLoop.cpp.o ninja: build stopped: subcommand failed.

chachako commented 4 years ago

Extra info: image

Naville commented 4 years ago

具体是什么符号没找到。你截图缺了一块

chachako commented 4 years ago

具体是什么符号没找到。你截图缺了一块

FAILED: lib/clang/8.0.0/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib : && /Library/Developer/CommandLineTools/usr/bin/c++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -Wall -std=c++11 -Wno-unused-parameter -Os -DNDEBUG -arch i386 -arch x86_64 -arch x86_64h -dynamiclib -Wl,-headerpad_max_install_names -stdlib=libc++ -lc++ -lc++abi -fapplication-extension -mmacosx-version-min=10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -nodefaultlibs -o lib/clang/8.0.0/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib -install_name @rpath/libclang_rt.ubsan_minimal_osx_dynamic.dylib projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.osx.dir/ubsan_minimal_handlers.cc.o -Wl,-rpath,@loader_path/../lib -lc && cd /Users/dracula/Documents/Develop/Obfuscator/Build/lib/clang/8.0.0/lib/darwin && codesign --sign - /Users/dracula/Documents/Develop/Obfuscator/Build/lib/clang/8.0.0/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS) ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libc++abi.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libc++abi.tbd ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libc++.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libc++.tbd ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libc.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libc.tbd Undefined symbols for architecture i386: "_abort", referenced from: abort_with_message(char const) in ubsan_minimal_handlers.cc.o (maybe you meant: _ubsan_handle_cfi_check_fail_minimalabort, ubsan_handle_pointer_overflow_minimal_abort , _ubsan_handle_nullability_arg_minimal_abort , _ubsan_handle_nonnull_return_minimalabort , ubsan_handle_implicit_conversion_minimal_abort , _ubsan_handle_mul_overflow_minimalabort , ubsan_handle_function_type_mismatch_minimalabort , ubsan_handle_invalid_builtin_minimal_abort , _ubsan_handle_float_cast_overflow_minimalabort , ubsan_handle_load_invalid_value_minimal_abort , _ubsan_handle_nonnull_arg_minimal_abort , _ubsan_handle_alignment_assumption_minimalabort , ubsan_handle_type_mismatch_minimal_abort , _ubsan_handle_divrem_overflow_minimalabort , ubsan_handle_add_overflow_minimal_abort , _ubsan_handle_negate_overflow_minimalabort , ubsan_handle_out_of_bounds_minimalabort , ubsan_handle_vla_bound_not_positive_minimal_abort , _ubsan_handle_shift_out_of_bounds_minimal_abort , _ubsan_handle_nullability_return_minimalabort , ubsan_handle_sub_overflow_minimal_abort ) "strlen", referenced from: ubsan_handle_type_mismatch_minimal in ubsan_minimal_handlers.cc.o report_this_error(void) in ubsan_minimal_handlers.cc.o message(char const) in ubsan_minimal_handlers.cc.o _ubsan_handle_alignment_assumption_minimal in ubsan_minimalhandlers.cc.o ubsan_handle_add_overflow_minimal in ubsan_minimal_handlers.cc.o _ubsan_handle_sub_overflow_minimal in ubsan_minimalhandlers.cc.o ubsan_handle_mul_overflow_minimal in ubsan_minimal_handlers.cc.o ... "_write$UNIX2003", referenced from: ___ubsan_handle_type_mismatch_minimal in ubsan_minimal_handlers.cc.o report_this_error(void) in ubsan_minimal_handlers.cc.o message(char const*) in ubsan_minimal_handlers.cc.o _ubsan_handle_alignment_assumption_minimal in ubsan_minimalhandlers.cc.o ubsan_handle_add_overflow_minimal in ubsan_minimal_handlers.cc.o _ubsan_handle_sub_overflow_minimal in ubsan_minimalhandlers.cc.o ubsan_handle_mul_overflow_minimal in ubsan_minimal_handlers.cc.o ... ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) [14/1953] Building CXX object tools/ll...on.dir/TargetOptionsCommandFlags.cpp.o ninja: build stopped: subcommand failed.

Naville commented 4 years ago

Catalina缺32位的运行库,你得动手禁用32位的编译

chachako commented 4 years ago

Catalina缺32位的运行库,你得动手禁用32位的编译

@Naville 感谢,这个错误已经不会出现了,但是在编译的最后阶段出现了一个新的错误导致编译终止:

➜ build git:(release_80) ✗ ninja
[4/8] Linking CXX executable bin/debugserver FAILED: bin/debugserver : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -Wno-gnu-zero-variadic-macro-arguments -Wno-zero-length-array -Os -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -stdlib=libc++ -Wl,-sectcreate,TEXT,info_plist,/Users/dracula/Documents/Develop/Obfuscator/Hikari/tools/lldb/tools/debugserver/source/../resources/lldb-debugserver-Info.plist -Wl,-dead_strip tools/lldb/tools/debugserver/source/CMakeFiles/debugserver.dir/debugserver.cpp.o -o bin/debugserver -Wl,-rpath,@loader_path/../lib lib/liblldbDebugserverCommon.a -framework Cocoa -framework CoreFoundation -framework Foundation lib/liblldbDebugserverArchSupport.a lib/liblldbDebugserverDarwin_DarwinLog.a -lcompression && cd /Users/dracula/Documents/Develop/Obfuscator/Hikari/build/tools/lldb/tools/debugserver/source && /usr/local/Cellar/cmake/3.17.0_1/bin/cmake -E env CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate xcrun codesign -s lldb_codesign --entitlements /Users/dracula/Documents/Develop/Obfuscator/Hikari/tools/lldb/resources/debugserver-macosx-entitlements.plist /Users/dracula/Documents/Develop/Obfuscator/Hikari/build/bin/debugserver error: The specified item could not be found in the keychain. [5/8] Python script sym-linking LLDB Python API ninja: build stopped: subcommand failed.

剩余三个文件编译,卡在这里无法进行下一步 ninja install, bin 目录下 clang 已经编译好了

Naville commented 4 years ago

DEBUGSERVER要改成用系统的debugserver。需要的指令Wiki的傻瓜化脚本里已经带上了

chachako commented 4 years ago

DEBUGSERVER要改成用系统的debugserver。需要的指令Wiki的傻瓜化脚本里已经带上了

系统的debugserver路径在什么地方呢...有具体的修改方法吗

Naville commented 4 years ago

照着Wiki的脚本,有一个cmake参数

chachako commented 4 years ago

@Naville ...恕我愚昧,我应该是完全使用的wiki中的脚本来执行的,为此我还重新执行了一遍

➜ build git:(release_80) ✗ cmake -G "Ninja" -DLLDB_CODESIGN_IDENTITY='' -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on -DLLVM_CREATE_XCODE_TOOLCHAIN=on -DCMAKE_INSTALL_PREFIX=~/Library/Developer/ ../
-- Found libtool - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -- Native target architecture is X86 -- Threads enabled. -- Doxygen disabled. -- Go bindings disabled. -- Found ld64 - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) -- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) -- OCaml bindings disabled. -- Could NOT find Python module pygments -- Could NOT find Python module pygments.lexers.c_cpp -- Could NOT find Python module yaml -- LLVM host triple: x86_64-apple-darwin19.4.0 -- LLVM default target triple: x86_64-apple-darwin19.4.0 -- Building with -fPIC -- Constructing LLVMBuild project information -- Linker detection: ld64 -- Targeting AArch64 -- Targeting AMDGPU -- Targeting ARM -- Targeting BPF -- Targeting Hexagon -- Targeting Lanai -- Targeting Mips -- Targeting MSP430 -- Targeting NVPTX -- Targeting PowerPC -- Targeting Sparc -- Targeting SystemZ -- Targeting WebAssembly -- Targeting X86 -- Targeting XCore -- Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE) -- Linker detection: ld64 -- Linker detection: ld64 -- Found SDK version 10.15.4 -- Linker detection: ld64 -- Linker detection: ld64 CMake Warning (dev) at projects/compiler-rt/CMakeLists.txt:62 (set): implicitly converting 'BOOLEAN' to 'STRING' type. This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at projects/compiler-rt/CMakeLists.txt:65 (set): implicitly converting 'BOOLEAN' to 'STRING' type. This warning is for project developers. Use -Wno-dev to suppress it.

-- Got ld supported ARCHES: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em -- Toolchain supported arches: armv6;armv7;armv7s;arm64;arm64e;arm64_32;i386;x86_64;x86_64h;armv6m;armv7k;armv7m;armv7em -- Using cached valid architectures for osx. -- OSX supported arches: x86_64;x86_64h -- Using cached valid architectures for iossim. -- ios Simulator supported arches: i386;x86_64 -- Using cached valid architectures for ios. -- ios supported arches: armv6;armv7;armv7s;arm64;arm64e;armv7k -- Compiler-RT supported architectures: x86_64;x86_64h;i386;armv6;armv7;armv7s;arm64;arm64e;armv7k -- OSX supported arches: x86_64;x86_64h -- Using cached valid architectures for iossim. -- ios Simulator supported builtin arches: i386;x86_64 -- Using cached valid architectures for ios. -- ios supported builtin arches: armv6;armv7;armv7s;arm64;arm64e;armv7k -- Builtin supported architectures: i386;x86_64;x86_64h;armv7;armv7k;armv7s;arm64 -- Linker detection: ld64 -- Linker detection: ld64 -- OSX supported arches: x86_64;x86_64h -- Using cached valid architectures for iossim. -- ios Simulator supported builtin arches: i386;x86_64 -- Using cached valid architectures for ios. -- ios supported builtin arches: armv6;armv7;armv7s;arm64;arm64e;armv7k -- Builtin supported architectures: i386;x86_64;x86_64h;armv7;armv7k;armv7s;arm64 -- check-interception does nothing. -- sanitizer_common tests on "Darwin" will run against "asan" -- Clang version: 8.0.0 -- Could NOT find Z3 (missing: Z3_LIBRARIES Z3_INCLUDE_DIR) (Required is at least version "4.7.1") -- Performing Test LINKER_ORDER_FILE_WORKS -- Performing Test LINKER_ORDER_FILE_WORKS - Success -- LLD version: 8.0.0 -- LLDB version: 8.0.0 -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) -- Symbols (liblldb): exporting all symbols from the lldb namespace -- lldb debugserver: /Users/dracula/Documents/Develop/Obfuscator/Hikari/build/./bin/debugserver CMake Warning at tools/xcode-toolchain/CMakeLists.txt:60 (message): Failed to detect the version of an installed copy of Xcode, falling back to highest supported version. Set XCODE_VERSION to override.

-- Failed to find LLVM FileCheck -- git Version: v0.0.0-dirty -- Version: 0.0.0 -- Performing Test HAVE_THREAD_SAFETY_ATTRIBUTES -- failed to compile -- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile -- Performing Test HAVE_POSIX_REGEX -- success -- Performing Test HAVE_STEADY_CLOCK -- success -- Configuring done -- Generating done -- Build files have been written to: /Users/dracula/Documents/Develop/Obfuscator/Hikari/build

➜ build git:(release_80) ✗ ninja &&ninja install-xcode-toolchain && git clone https://github.com/HikariObfuscator/Resources.git ~/Hikari && rsync -a --ignore-existing /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ ~/Library/Developer/Toolchains/Hikari.xctoolchain/ && rm ~/Library/Developer/Toolchains/Hikari.xctoolchain/ToolchainInfo.plist [2/2] Linking CXX executable bin/debugserver FAILED: bin/debugserver : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -Wno-gnu-zero-variadic-macro-arguments -Wno-zero-length-array -Os -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -stdlib=libc++ -Wl,-sectcreate,TEXT,info_plist,/Users/dracula/Documents/Develop/Obfuscator/Hikari/tools/lldb/tools/debugserver/source/../resources/lldb-debugserver-Info.plist -Wl,-dead_strip tools/lldb/tools/debugserver/source/CMakeFiles/debugserver.dir/debugserver.cpp.o -o bin/debugserver -Wl,-rpath,@loader_path/../lib lib/liblldbDebugserverCommon.a -framework Cocoa -framework CoreFoundation -framework Foundation lib/liblldbDebugserverArchSupport.a lib/liblldbDebugserverDarwin_DarwinLog.a -lcompression && cd /Users/dracula/Documents/Develop/Obfuscator/Hikari/build/tools/lldb/tools/debugserver/source && /usr/local/Cellar/cmake/3.17.0_1/bin/cmake -E env CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate xcrun codesign -s lldb_codesign --entitlements /Users/dracula/Documents/Develop/Obfuscator/Hikari/tools/lldb/resources/debugserver-macosx-entitlements.plist /Users/dracula/Documents/Develop/Obfuscator/Hikari/build/bin/debugserver error: The specified item could not be found in the keychain. ninja: build stopped: subcommand failed.

Naville commented 4 years ago

有意思。你可以试试lldb的源码目录下有另一种方式教你绕过这个问题

Naville commented 4 years ago

https://github.com/HikariObfuscator/Hikari/tree/release_80/tools/lldb/docs 这个。或者直接把tools/lldb目录整个删掉

chachako commented 4 years ago

或者直接把tools/lldb目录整个删掉

编译通过了!这玩意有什么影响吗

Naville commented 4 years ago

如果你头脑发热要用混淆的工具链调试的话可能会有影响

chachako commented 4 years ago

如果你头脑发热要用混淆的工具链调试的话可能会有影响

目前来说只用到 NDK 移植,应该不会影响吧

Naville commented 4 years ago

么的问题

chachako commented 4 years ago

另外做一个补充,移植到 NDK R21 后编译会出现一个错误并伴随着一大堆警告

部分输出

CMakeFiles/dexposed_c.dir/archs/arm/arm32/relocate/code_relocate_arm32.cpp.o:code_relocate_arm32.cpp:.LHikariConditionalLocalIndirectBranchingTable.51: warning: relocation refers to discarded section CMakeFiles/dexposed_c.dir/archs/arm/arm32/relocate/code_relocate_arm32.cpp.o:code_relocate_arm32.cpp:.LHikariConditionalLocalIndirectBranchingTable.52: warning: relocation refers to discarded section CMakeFiles/dexposed_c.dir/archs/arm/arm32/relocate/code_relocate_arm32.cpp.o:code_relocate_arm32.cpp:.LHikariConditionalLocalIndirectBranchingTable.52: warning: relocation refers to discarded section CMakeFiles/dexposed_c.dir/archs/arm/arm32/relocate/code_relocate_arm32.cpp.o:code_relocate_arm32.cpp:.LHikariConditionalLocalIndirectBranchingTable.53: warning: relocation refers to discarded section CMakeFiles/dexposed_c.dir/archs/arm/arm32/relocate/code_relocate_arm32.cpp.o:code_relocate_arm32.cpp:.LHikariConditionalLocalIndirectBranchingTable.53: warning: relocation refers to discarded section CMakeFiles/dexposed_c.dir/archs/arm/arm32/relocate/code_relocate_arm32.cpp.o:code_relocate_arm32.cpp:.LHikariConditionalLocalIndirectBranchingTable.54: warning: relocation refers to discarded section CMakeFiles/dexposed_c.dir/archs/arm/arm32/relocate/code_relocate_arm32.cpp.o:code_relocate_arm32.cpp:.LHikariConditionalLocalIndirectBranchingTable.54: warning: relocation refers to discarded section /Users/dracula/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: treating warnings as errors clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.

参考 NDK 17 error: treating warnings as errors,通过在 CMakeLists.txt 中加入 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wall -v -Wl,--no-fatal-warnings") 暂时解决问题。

不知道🈶🈚️更好的方案