Apple cctools and ld64 port for Linux, *BSD and macOS

Overview

Apple cctools and ld64 port for Linux, *BSD and macOS

Current Version: cctools: 973.0.1, ld64: 609.
Originally ported by cjacker.

SUPPORTED HOSTS

SUPPORTED OPERATING SYSTEMS:

Linux, Android (Termux), FreeBSD,
Mac OS X, iOS, OpenBSD and NetBSD

SUPPORTED HOST ARCHITECTURES:

x86, x86_64, arm, arm64/aarch64

SUPPORTED TARGET ARCHITECTURES

armv6, armv7, armv7s, arm64, arm64e,
arm64_32 (untested), i386, x86_64, x86_64h,
armv6m, armv7k, armv7m and armv7em

arm64e requires Apple LLVM/Clang.

SUPPORTED TARGET OPERATING SYSTEMS

macOS, iOS, tvOS, watchOS, bridgeOS, Mac Catalyst,
iOS Simluator, watchOS Simulator, DriverKit

Not all of the targets have been tested.

DEPENDENCIES

Clang 3.4+

SDKs with .tdb stubs (>= Xcode 7) require the TAPI library to be installed.
=> https://github.com/tpoechtrager/apple-libtapi

musl-libc based systems require the musl-fts library to be installed. => https://github.com/pullmoll/musl-fts

Optional, but recommended:

llvm-devel (For Link Time Optimization Support)
uuid-devel (For ld64 -random_uuid Support)
llvm-devel + xar-devel (For ld64 -bitcode_bundle Support)
libdispatch (For parallelism in ld64 / libcodedirectory.c)

You can find xar here.
Do not install libxar-dev on Ubuntu, it's a different package.

INSTALLATION

Install Apple's TAPI library:

This step is only required if you intend to use SDKs with .tdb stubs.

git clone https://github.com/tpoechtrager/apple-libtapi.git
cd apple-libtapi
[INSTALLPREFIX=/home/user/cctools] ./build.sh
./install.sh

Install cctools and ld64:

git clone https://github.com/tpoechtrager/cctools-port.git
cd cctools-port/cctools
./configure \
    [--prefix=/home/user/cctools] \
    [--with-libtapi=/home/user/cctools] \
    [--target=
   
    ] \
    [--with-llvm-config=...]
make
make install

   

target = i386-apple-darwin11, x86_64-apple-darwin11, arm-apple-darwin11, ...

TRAVIS CI

Build Status

Comments
  • arm64 support

    arm64 support

    I am trying to build cctools for arm64 under Fedora Linux

    ./configure --target=arm64-apple-darwin checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... Invalid configuration arm64-apple-darwin': machinearm64-apple' not recognized configure: error: /bin/sh ./config.sub arm64-apple-darwin failed

    Maybe you know what can cause this issue?

    opened by dmigous 29
  • Build failed on Cygwin

    Build failed on Cygwin

    Hi, I tried building the cctools , but when I run make it fails at this point

    make[1]: Entering directory '/home/Damilare/cctools-port/cctools/libobjc2'
    /bin/sh ../libtool    --mode=compile gcc -DPACKAGE_NAME=\"cctools\" -DPACKAGE_TARNAME=\"cctools\" -DPACKAGE_VERSION=\"877.5\" -DPACKAGE_STRING=\"cctools\ 877.5\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DEMULATED_HOST_CPU_TYPE=12 -DEMULATED_HOST_CPU_SUBTYPE=0 -D__STDC_LIMIT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -DHAVE_UUID_UUID_H=1 -I.  -DTYPE_DEPENDENT_DISPATCH -DGNUSTEP -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 -D__BSD_VISIBLE=1 -D_DEFAULT_SOURCE=1 -DNO_SELECTOR_MISMATCH_WARNINGS  -std=gnu99 -Wall -O3 -D__LARGE64_FILES -fno-PIC -c -o libobjc_la-NSBlocks.lo `test -f 'NSBlocks.m' || echo './'`NSBlocks.m
    libtool: compile:  gcc -DPACKAGE_NAME=\"cctools\" -DPACKAGE_TARNAME=\"cctools\" -DPACKAGE_VERSION=\"877.5\" "-DPACKAGE_STRING=\"cctools 877.5\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DEMULATED_HOST_CPU_TYPE=12 -DEMULATED_HOST_CPU_SUBTYPE=0 -D__STDC_LIMIT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -DHAVE_UUID_UUID_H=1 -I. -DTYPE_DEPENDENT_DISPATCH -DGNUSTEP -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 -D__BSD_VISIBLE=1 -D_DEFAULT_SOURCE=1 -DNO_SELECTOR_MISMATCH_WARNINGS -std=gnu99 -Wall -O3 -D__LARGE64_FILES -fno-PIC -c NSBlocks.m  -DDLL_EXPORT -DPIC -o .libs/libobjc_la-NSBlocks.o
    gcc: error: spawn: No such file or directory
    Makefile:545: recipe for target 'libobjc_la-NSBlocks.lo' failed
    make[1]: *** [libobjc_la-NSBlocks.lo] Error 1
    make[1]: Leaving directory '/home/Damilare/cctools-port/cctools/libobjc2'
    Makefile:402: recipe for target 'all-recursive' failed
    make: *** [all-recursive] Error 1
    
    opened by darmie 23
  • Unable to create target

    Unable to create target

    After I finally got all dependencies compiled including cctools, I am getting this error

     ./arm-apple-darwin11-clang ../../test.c -arch arm64 -c
    error: unable to create target: 'No available targets are compatible with this triple.'
    1 error generated.
    
    opened by darmie 15
  • Any chance for an iPhoneSimulator build?

    Any chance for an iPhoneSimulator build?

    I tried building the cross tools against the iOS simulator SDK. It successfully compiles everything, but then fils in the final step when checking the toolchain.

    *** checking toolchain ***
    
    ld: file not found: /usr/lib/system/libsystem_kernel.dylib for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    Indeed that particular file does not exist, as it's named libsystem_sim_kernel.dylib in the simulator SDK. Any ideas where I should look to correct this one last issue?

    Out of curiosity I tried simlinking the above file to the version without _sim_ in the name, but it got me an infinite linker loop or something i386-apple-darwin11-ld: ./ld.hpp:109: const ld::File::Ordinal ld::File::Ordinal::nextCounter() const: Assertioncounter() < 0xffff' failed.`

    opened by karalabe 12
  • debug builds

    debug builds

    When I tried to build debug builds with clang-3.5 it complained that cant find dsymutil. And back then I couldn't find dsymutil port for linux that will work for me. Now I discovered that clang-3.7 has some llvm-dsymutil, I made symlink /usr/bin/dsymutil => llvm-dsymutil

    And now I am getting following error once any -g flag e.g -g3 present

    [email protected]:/vagrant/target/ios/arm-apple-darwin/armv7/debug/ambrosia_adapters/tmp$ /vagrant/target/native/release/apple_cctools/arm-apple-darwin/usr/bin/arm-apple-darwin-clang -DHAVE_CONFIG_H  -miphoneos-version-min=7.1 -target arm-apple-darwin -arch armv7 -pipe -isysroot /home/vagrant/SDKs/iOS/iPhoneOS7.1.sdk -stdlib=libstdc++ -isystem /home/vagrant/SDKs/iOS/iPhoneOS7.1.sdk/usr/include/c++/4.2.1 -O0 -g ./conftest.c 
    error: failed to compute relocation: ARM_RELOC_VANILLA
    error: failed to compute relocation: ARM_RELOC_VANILLA
    error: failed to compute relocation: ARM_RELOC_VANILLA
    error: failed to compute relocation: ARM_RELOC_VANILLA
    error: failed to compute relocation: ARM_RELOC_VANILLA
    

    If somebody can help me, I'll be happy :-)

    opened by dmigous 10
  • Toolchain points to the wrong ldid executable

    Toolchain points to the wrong ldid executable

    How do I fix this? Toolchain is trying to use the ldid.exe that came along with cygwin64, do you have any idea how I can correct this?

          6 [main] ldid (12968) C:\cygwin64\bin\ldid.exe: *** fatal error - cygheap base mismatch detected - 0x1802F3408/0x180304408.
    This problem is probably due to using incompatible versions of the cygwin DLL.
    Search for cygwin1.dll using the Windows Start->Find/Search facility
    and delete all but the most recent version.  The most recent version *should*
    reside in x:\cygwin\bin, where 'x' is the drive on which you have
    installed the cygwin distribution.  Rebooting is also suggested if you
    are unable to find another cygwin DLL.
    
    opened by darmie 8
  • Fix sign issues in PowerPC relocation code.

    Fix sign issues in PowerPC relocation code.

    Now negative numbers are properly sign extended again. Fixes linking of STLport, which failed to link in the exception handling related section.

    The important part is that operands in arithemtic are signed again. Thus, if a substraction results in a negative number it is properly saved in an (u)int64_t value, formerly all upper 32bits were always unsed causing issues.

    opened by lordhoto 8
  • Usage example

    Usage example

    It is not exactly a issue, is more a begginer request.

    Could be nice have some usage example with a 'hello world' or a start point. I have compiled in Arch Linux i686 system and now i want make a 'hello world' to run on iPhone 3G but i don´t know how start it or where see an example.

    Could anyone put me in correct way please?

    Thanks in advance!

    opened by semeion 8
  • openssl issue while build iOS tool chain

    openssl issue while build iOS tool chain

    I got below erros while build iOS tool chain cctools$ ./configure --prefix=<path>/cctools --with-libtapi=<path>/cctools cctools$ make

    fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. Makefile:460: recipe for target 'libstuff_la-arch.lo' failed make[1]: *** [libstuff_la-arch.lo] Error 1 make[1]: Leaving directory '/mnt/hdd/opt/code/x-compiler/cctools-port/cctools/libstuff' Makefile:416: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1

    Please help me with above issue.

    opened by Dayananda87 7
  • arm64e display not support.

    arm64e display not support.

    It seems that support for arm64e has been substantially completed, but it is not supported on the display by the file command.

    arm-apple-darwin11-clang -arch arm64e -o hello hello.c
    file hello
    hello: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
    
    # iPhone7 Plus iOS11.2 jailbroken (arm64)
    sudo ldid -Sent.xml hello && sudo mv hello /usr/bin/
    hello
    Bad CPU type in executable
    
    opened by okanon 7
  • SDK version 10.0 and up not noticed by build.sh

    SDK version 10.0 and up not noticed by build.sh

    change the line where the SDK-Version is read from the archive name to: SDK_VERSION=$(echo $1 | grep -P -o "[0-9][0-9].[0-9]+" | head -1) if [ -z "$SDK_VERSION" ]; then SDK_VERSION=$(echo $1 | grep -P -o "[0-9].[0-9]+" | head -1) if [ -z "$SDK_VERSION" ]; then echo "iPhoneOS Version must be in the SDK filename!" 1>&2 exit 1 fi fi (there is surely a better way to do this, I am not very familiar with sh scripts) or something similar so that version 10.0 and up are noticed by the script.

    opened by SimonSuckut 7
  • Cant compile with tapi on alpine linux

    Cant compile with tapi on alpine linux

    when i run

    ./configure --target=aarch64-apple-darwin14 --prefix=/root/ios-toolchain --with-libtapi=/root/ios-toolchain
    

    i get

    checking tapi/tapi.h and libtapi support... no
    configure: error: -- ERROR: Failed TAPI checks in /root/ios-toolchain
    

    tapi is installed, both in /usr and in /root/ios-toolchain, and there aren't any errors when compiling tapi, so idk whats wrong. I tried building tapi on arch (where everything works) and copying it over but i get the same error.

    opened by OldWorldOrdr 0
  • Could cctools-port be used to cross-compile R for iOS?

    Could cctools-port be used to cross-compile R for iOS?

    Hello.

    I am a novice linux user/programmer who would like to run the R statistical language natively on my iPad. As far as I can tell, no one has successfully cross-compiled R for iOS (one developer on the App Store has tried: "R Analyst" but the app is unable to perform many R functions). Yet, R successfully compiles on Mac OSX. I came across the cctool-port on github and was wondering if it might be able to help me cross-compile R for iOS. If so, I'm willing to learn/try cross-compiling to iOS on Linux (or via terminal on my MacOS) and would appreciate any additional tips beyond the instructions provided in the README.

    Thanks and Happy Holidays!

    opened by SugarRayLua 0
  • Releases outdate ?

    Releases outdate ?

    There have been no new releases since 2016, it would be nice to find the last stable tag to make a release because it's been a while since there has been one made This will help to ensure the sustainability of the project over time

    it would have been nice to have a new release for each version change.

    opened by tnagorran 2
  • codesign issue with files with space

    codesign issue with files with space

    Hi,

    Thank you very much for the sigtool addition! Just a small remark, it fails to sign files with spaces.

    In file /cctools/include/stuff/port.h On line 60: snprintf(codesign_command, sizeof(codesign_command), "%s -s - -f %s", codesign, filename);
    Can be replaced with something like (quotes added): snprintf(codesign_command, sizeof(codesign_command), "%s -s - -f '%s'", codesign, filename); \

    opened by etrinh 1
Releases(cctools-877.8-ld64-253.9-1)
Owner
Thomas Pöchtrager
Thomas Pöchtrager
Tiny implementation of the GNU/Linux CGroupFS (sans resource controllers) as a PUFFS or FUSE filesystem for BSD platforms

CGrpFS CGrpFS is a tiny implementation of the GNU/Linux CGroup filesystem for BSD platforms. It takes the form of a either a PUFFS or FUSE filesystem,

null 13 Nov 8, 2022
Qt5 "Hello, world!" app for Linux, BSD, Windows, Mac.

hello world in qt5 Contributions in all forms (code, bug reports, community engagement, localization, etc) are warmly welcomed. Development activity I

Jakob Flierl 2 Jan 26, 2022
Allows to swap the Fn key and left Control key and other tweaks on Macbook Pro and Apple keyboards in GNU/Linux

A patched hid-apple kernel module UPDATE August 2020: swap_fn_leftctrl is now built-in in Linux 5.8 ?? UPDATE Jun 2020: New feature added (swap_fn_f13

Zakhar Semenov 305 Dec 29, 2022
My experiments with Linux for the Apple M1 platform, based on Asahi and Corellium patches

Linux kernel ============ There are several guides for kernel developers and users. These guides can be rendered in a number of formats, like HTML an

Danny Lin 9 Oct 24, 2021
Utility to install kexts, Frameworks and PrivateFrameworks in the System of macOS. For macOS Monterey 12 and Big Sur 11

Command-Line-SnapShot-Mounter Credit: chris1111 Apple This utility uses the macOS terminal Command Line SnapShot Mounter is an utility that allows you

chris1111 23 Jan 8, 2023
Macos-arm64-emulation - A guide for emulating macOS arm64e on an x86-based host.

macos-arm64-emulation Use the following guide to download and configure all of the necessary tools and files for emulating the macOS arm64e kernel. Th

Cylance 233 Jan 7, 2023
BSD-licensed Yamaha FM sound cores (OPM, OPN, OPL, and others)

ymfm ymfm is a collection of BSD-licensed Yamaha FM sound cores (OPM, OPN, OPL, and others), written by Aaron Giles Supported environments This code s

Aaron Giles 163 Dec 31, 2022
A bootloader and experimentation playground for Apple Silicon

m1n1: an experimentation playground for Apple Silicon (And to some extent a Linux bootloader) Building You need an aarch64-linux-gnu-gcc cross-compile

Asahi Linux 2.5k Dec 27, 2022
Upload arbitrary data via Apple's Find My network.

Send My Send My allows you to to upload abritrary data from devices without an internet connection by (ab)using Apple's Find My network. The data is b

Positive Security 1.5k Dec 26, 2022
Apple TV 2/3 Jailbreak

Blackb0x Apple TV 2/3 Jailbreak Untethered jailbreak tool that runs on modern versions of macOS. Devices supported: Apple TV 3,2 (A1469) (iOS 8.4.x un

null 362 Dec 30, 2022
An apple IIe emulator for the Raspberry Pi.

ApplePi "applepi" is an apple IIe emulator for the Raspberry Pi, but can be built (I think) on most Linux distributions. It runs easily on a Pi4B, and

J.B.Ward 11 Jul 31, 2022
Swift Framework for Apple Health Integration with Terra Enabling Developers LTD.

TerraSwift This library allows developers to connect to TERRA ENABLING DEVELOPERS LTD. through Swift (implemented with Swift5.0). This library uses He

null 6 Oct 14, 2022
Protobuf for Proxyman app - Include Apple Silicon & Intel architecture

Protobuf for Proxyman macOS app Protobuf for Proxyman app - Include Apple Silicon & Intel architecture How to build Open the project on the latest Xco

Proxyman 6 Nov 29, 2021
Get the current average CPU frequency on Apple M1 chips.

M1 CPU Frequency Get the current average CPU frequency on Apple M1 chips. Usage Download the precompiled binary from the releases and run it in the te

BitesPotatoBacks 20 Jan 3, 2023
Adds proper Apple Pencil support to Unity's InputSystem.

This project aims to create an Apple Pencil device for Unity's InputSystem package. The problem: Unity does not fully integrate with Apple Pencil. App

Oliver Smith 13 Dec 11, 2022
A pre-boot execution environment for Apple boards built on top of checkra1n

archOS A pre-boot execution environment for Apple boards built on top of checkra1n - currently based off the Checkra1n/PongoOS Repo. Building on macOS

ScarletAI 2 Jan 17, 2022
Fairplay research - Some RE work on Apple's Fairplay DRM

Poor Man's Kernel Debuger This project loads FairplayIOKit kernel driver into userspace and make it possible for LLDB to debug How to Compile In proje

pwnorz 134 Nov 24, 2022
A library to handle Apple Property List format in binary or XML

libplist A small portable C library to handle Apple Property List files in binary or XML format. Features The project provides an interface to read an

libimobiledevice 433 Dec 26, 2022
C Library for Apple Firmware (Amalgam)

DeviceTree Minimal code to deal with Apple's DeviceTree format. The Makefile builds dt and pmgr binaries, but you should also be able to use dt.c + dt

Hack Different 26 Sep 30, 2022