rayhunter icon indicating copy to clipboard operation
rayhunter copied to clipboard

./install-common.sh: line 20: ./serial-macos-latest/serial: Bad CPU type in executable

Open steve5054 opened this issue 9 months ago • 13 comments

Running ./install-mac.sh on a 2019 Macbook Pro (2.6 GHz 6-Core Intel Core i7) I get the following error:

% ./install-mac.sh
Using adb at ./platform-tools/adb Force a switch into the debug mode to enable ADB ./install-common.sh: line 20: ./serial-macos-latest/serial: Bad CPU type in executable

steve5054 avatar Mar 08 '25 23:03 steve5054

The tool 'serial-macos-latest' in the release.tar is a binary compiled for 'apple silicon' / arm. To compile it yourself for your x86/amd64 macbook :

  • install rust following https://www.rust-lang.org/tools/install
  • install git
  • in shell do something similar to this:
> git clone https://github.com/EFForg/rayhunter
> cd rayhunter/serial
> cargo build --release
> cp ../target/release/serial /location/of/your/releasebinaries/serial-macos-latest/serial

Effectively replacing the 'wrong' binary. Of course you could compile the whole rayhunter project yourself, but this requires gcc installed and other dependencies.

rbomze avatar Mar 09 '25 10:03 rbomze

It would be trivial to modify the install script(s) to handle that more elegantly. Could I trouble someone with an ARM based mac to post the output of: uname -a and uname -m?

If there's interest in making both binaries available it would be just as easy to have the script download and use the correct one.

allpoints avatar Mar 10 '25 19:03 allpoints

@allpoints

$ uname -a
<COMPUTER_NAME> 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec  6 19:03:40 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6041 arm64
$ uname -m
arm64

thejoelpatrol avatar Mar 10 '25 22:03 thejoelpatrol

Unfortunately @rbomze 's suggestion doesn't work, at least not as trivially as it seemed it might. The compile gets hung up on missing x86_64 symbols somewhere in/around liblibusb1_sys and that's the point at which I lost interest because I didn't feel like doing a full build of the entire project. :)

So if @allpoints wants to hook us poor x86 Mac owners up with a working serial binary, I'd be into it.

rossgrady avatar Mar 11 '25 00:03 rossgrady

@thejoelpatrol thanks, I'm can fold that into the install once i get word on if https://github.com/EFForg/rayhunter/pull/133 has been accepted.

@rossgrady I'll see if I can find some time later today to do that

allpoints avatar Mar 11 '25 15:03 allpoints

Ran into this and got a successful install on an older MacBook (Intel dual core), running macOS 14.7.4.

To get the replacement 'serial', these were my steps (vanilla MacBook):

  • Get the release from; https://github.com/EFForg/rayhunter/releases
  • Install Mac 'xcode' tools
  • Install Rust (which includes Cargo)
  • Get the source tree download ZIP, unzip into default rayhunter-main directory
  • Build the 'serial' executable in default directory : cargo build --release --bin='serial'
  • Copy rayhunter-main/target/release/serial to the the serial-macos-latest directory

Now, the install-mac.sh script should run. Make sure the Orbis is connected.

Note: many thanks to Cooper Quintin for the help.

wisxxx avatar Mar 11 '25 18:03 wisxxx

Update (adding to the above from @wisxxx ):

On my 2020 Intel Mac running Sequoia, something about my toolchain (I'm not a Rust dev but heaven only knows what's left lying around) was throwing a bunch of _________ was built for newer 'macOS' version (14.0) than being linked (10.12)

Since I'm building just-for-me and not for lowest-common-denominator distribution, Teh Internets helped me to realize I could do export MACOSX_DEPLOYMENT_TARGET=14.0 and then the above steps worked A-OK for me.

I now have a rooted Orbis device running Rayhunter. Thanks, y'all!

rossgrady avatar Mar 11 '25 21:03 rossgrady

ack, yeah this is unfortunately a limitation of the Github-hosted CI we're using to build our releases -- there's no (free) way to build for x86 macOS. i think for now, we'll add a section to the README covering what @wisxxx outlined.

wgreenberg avatar Mar 11 '25 23:03 wgreenberg

I tried the @wisxxx solution, but can't get it to link. I'm on a Intel MacBook running Sequoia 15.3.1.

rayhunter-main % cargo build --release --bin='serial'          
   Compiling pkg-config v0.3.30
   Compiling cc v1.0.86
   Compiling libc v0.2.155
   Compiling rusb v0.9.3
   Compiling libusb1-sys v0.6.4
   Compiling serial v0.1.0 (/Users/bjn/Downloads/rayhunter-main/serial)
error: linking with `cc` failed: exit status: 1
  |
  = note: env -u IPHONEOS_DEPLOYMENT_TARGET -u TVOS_DEPLOYMENT_TARGET -u XROS_DEPLOYMENT_TARGET LC_ALL="C" PATH="/Users/bjn/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin:/usr/local/opt/ruby/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/bjn/.cargo/bin:/Users/bjn/Library/Application Support/JetBrains/Toolbox/scripts" VSLANG="1033" ZERO_AR_DATE="1" "cc" "/var/folders/sb/qpqq2dkn18j_bhzn61zf7bbh0000gp/T/rustcYHe9pQ/symbols.o" "<3 object files omitted>" "/Users/bjn/Downloads/rayhunter-main/target/release/deps/{librusb-f63a3da3d4898c6c.rlib,liblibusb1_sys-4c208c2801badf86.rlib,liblibc-a7c6ea23d57440a6.rlib}" "/Users/bjn/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/{libstd-4342b9106d0415dd.rlib,libpanic_unwind-0a79a6ecf5b18530.rlib,libobject-84e437265aa7041b.rlib,libmemchr-30ebf9d2fcf0bfc8.rlib,libaddr2line-dbfe74fe37aade7e.rlib,libgimli-85a50da1374c89c1.rlib,librustc_demangle-5db1266bfa58bba4.rlib,libstd_detect-e9afbee47cd520d6.rlib,libhashbrown-959071037b1ad0aa.rlib,librustc_std_workspace_alloc-2a434012e00a54bc.rlib,libminiz_oxide-2a0f0a883febe6c2.rlib,libadler-be50c1a262537f4d.rlib,libunwind-07189d75869ed30f.rlib,libcfg_if-696a5bc7b60e0977.rlib,liblibc-4b8d08ad7d2ea874.rlib,liballoc-358cac0c3ed5a5a5.rlib,librustc_std_workspace_core-f56758809865f8ac.rlib,libcore-c79541fdd52d93c7.rlib,libcompiler_builtins-ee44a15358384055.rlib}" "-framework" "CoreFoundation" "-framework" "IOKit" "-framework" "Security" "-liconv" "-lSystem" "-lc" "-lm" "-arch" "x86_64" "-mmacosx-version-min=10.12.0" "-L" "/Users/bjn/Downloads/rayhunter-main/target/release/build/libusb1-sys-a958932b394c5c36/out" "-o" "/Users/bjn/Downloads/rayhunter-main/target/release/deps/serial-3fe2732585093e50" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: Undefined symbols for architecture x86_64:
            "___isPlatformVersionAtLeast", referenced from:
                _darwin_capture_release_interface in liblibusb1_sys-4c208c2801badf86.rlib[4](0e3aad1164bcc6fc-darwin_usb.o)
                _darwin_detach_kernel_driver in liblibusb1_sys-4c208c2801badf86.rlib[4](0e3aad1164bcc6fc-darwin_usb.o)
                _darwin_attach_kernel_driver in liblibusb1_sys-4c208c2801badf86.rlib[4](0e3aad1164bcc6fc-darwin_usb.o)
                _darwin_reenumerate_device in liblibusb1_sys-4c208c2801badf86.rlib[4](0e3aad1164bcc6fc-darwin_usb.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `serial` (bin "serial") due to 1 previous error

hoopgeek avatar Mar 12 '25 03:03 hoopgeek

@hoopgeek I ran into the same issue on MacOs 14.7.4.

mmilleror avatar Mar 13 '25 03:03 mmilleror

@mmilleror , solved. Add the following to ~/.cargo/config

[target.x86_64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

Found this answer here: https://stackoverflow.com/questions/28124221/error-linking-with-cc-failed-exit-code-1

hoopgeek avatar Mar 13 '25 16:03 hoopgeek

I successfully got this working on an Intel Mac (macOS 14.6.1). If anyone wants to see a step-by-step here's what worked:

  1. Add the following to ~/.cargo/config to fix the linking issues:
[target.x86_64-apple-darwin]
rustflags = [
   "-C", "link-arg=-undefined",
   "-C", "link-arg=dynamic_lookup",
]
[target.aarch64-apple-darwin]
rustflags = [
   "-C", "link-arg=-undefined",
   "-C", "link-arg=dynamic_lookup",
]
  1. Build the Intel-compatible serial tool:
cd rayhunter-0.2.5/serial
cargo build --release --bin='serial'
  1. Copy the compiled binary to replace the ARM version:
cp target/release/serial /path/to/release/serial-macos-latest/serial
  1. If you see "adb: more than one device/emulator", set the specific device:
export ANDROID_SERIAL=<your_device_id>  # Get ID from `adb devices`
  1. Run the installation script:
./install-mac.sh

Just as expected, the web interface is available at http://localhost:8080 after installation.

Credit to @hoopgeek for the Cargo config fix and @wisxxx for the initial compilation steps.

NyarlaCat avatar Mar 13 '25 19:03 NyarlaCat

@hoopgeek I had the same experience as @NyarlaCat. I was able to flash my device and collect packets.

mmilleror avatar Mar 14 '25 04:03 mmilleror

Since 0.3.0 the entire installer has been rewritten in Rust, and we also have apple silicon binaries.

untitaker avatar Jun 04 '25 20:06 untitaker