LLVM (iOS API)
别忘了submodules
只有7.0能在iOS16上使用,不要尝试去用最新版本,能编译无法在iOS16运行。

xcbosa 0d6527c4f3 Move submodules to self host 2 жил өмнө
benchmarks 18c6fab107 Pull google/benchmark library to the LLVM tree 7 жил өмнө
bindings 732f95ff9a Reapply r374743 with a fix for the ocaml binding 5 жил өмнө
cmake d35e5f8dde [CMake] [WinMsvc] Look for includes and libs in ${MSVC_BASE}/atlmfc 5 жил өмнө
docs d00dbb86c0 [docs][llvm-ar] Update llvm-ar command guide 5 жил өмнө
examples 88e224ab97 [examples] Add a dependency on ExecutionEngine to LLJITWithObjectCache example. 5 жил өмнө
frameworks c9f456a78b Edited bootstrap.sh for xcframework generation 5 жил өмнө
include 195e132a08 Merge branch 'master' of https://github.com/llvm-mirror/llvm 5 жил өмнө
lib 1d90413cd4 Avoid using signal() too much, for cohabitation with other commands 5 жил өмнө
libffi @ 45875da4bc a4345c19ad Added Package.swift, 5 жил өмнө
projects 195e132a08 Merge branch 'master' of https://github.com/llvm-mirror/llvm 5 жил өмнө
resources cb2dfa6478 In MSVC builds embed a VERSIONINFO resource in our exe and DLL files. 10 жил өмнө
runtimes 4ead439585 Adding support for overriding LLVM_ENABLE_RUNTIMES for runtimes builds. 5 жил өмнө
test 2c4ca6832f [InstCombine] Signed saturation patterns 5 жил өмнө
tools 781e843466 Committed changes to lld 5 жил өмнө
unittests 672893cf12 [Alignment][NFC] Attributes use Align/MaybeAlign 5 жил өмнө
utils 719615b78f gn build: Merge r375483 5 жил өмнө
.arcconfig 0e050ed9a8 [llvm] Set up .arcconfig to point to Diffusion L repository 7 жил өмнө
.clang-format 742e43f807 Test commit. 11 жил өмнө
.clang-tidy ba3936b0ea Disable tidy checks with too many hits 6 жил өмнө
.gitattributes a0ae292f06 Fix the "git modified" issue on the preserve-comments-crlf.s. 6 жил өмнө
.gitignore 9ac2d30839 gitignore: Ignore Qt Creator project configuration files. NFC 6 жил өмнө
.gitmodules 0d6527c4f3 Move submodules to self host 2 жил өмнө
CMakeLists.txt 820be7b079 Add few docs and implementation of strcpy and strcat. 5 жил өмнө
CODE_OWNERS.TXT 970d21048e Update email address in CODE_OWNERS 6 жил өмнө
CREDITS.TXT 8c5bc90b46 Update email address. 6 жил өмнө
LICENSE.TXT 2fea5b324e Fix typos throughout the license files that somehow I and my reviewers 6 жил өмнө
LLVMBuild.txt 6b547686c5 Update the file headers across all of the LLVM projects in the monorepo 6 жил өмнө
Package.swift c70f694c39 Forgot a , in Package.swift 5 жил өмнө
README.txt f44b57907a Edited README for archiving 4 жил өмнө
RELEASE_TESTERS.TXT e253500cfc Update the list of platforms & archs 6 жил өмнө
bootstrap.sh c9f456a78b Edited bootstrap.sh for xcframework generation 5 жил өмнө
configure caeade4234 Remove autoconf support 9 жил өмнө
libffi-3.2.1_patch ab55c93099 Patch for automatic compiltion of libffi (don't try to compile armv7) 7 жил өмнө
libffi.patch a4345c19ad Added Package.swift, 5 жил өмнө
llvm.spec.in 4cfe1aca69 Update structured references to the license to the new license. 6 жил өмнө
project.pbxproj 8f278533fc Edited project, now with frameworks 7 жил өмнө

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain a forked source code
for LLVM, a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.

iOS version specific information
================================

** This repository is now archived. Please move to https://github.com/holzschu/llvm-project for an up-to-date version of LLVM for iOS **

This is a very experimental port. It's is designed to work inside ios_system
(https://github.com/holzschu/ios_system), which itself is supposed to be
embedded inside shell applications such as OpenTerm or Blink:
- https://github.com/louisdh/terminal
- https://github.com/holzschu/blink

Compilation of the entire package takes around 20h (divided by the number of
cores you can give to the compiler). For this reason, even the scripts are
not fully guaranteed to work.

The steps for compilation are:
- get clang and lld as submodules: git submodule update --init --recursive
- get libcxx and libcxxabi as packages
- compile LLVM, clang, lld, libcxx and libcxxabi for OSX
- move libcxx and libcxxabi out of the way
- get libffi and compile it
- make sure ios_system has been compiled, and if not compile it.
- compile LLVM and clang for iOS (that's the long step)

"bootstrap.sh" in this directory takes care of all these steps. Remember,
you have time for a long walk in the woods while it compiles.

Once you have compiled everything, add the binaries you want (at least clang and lli)
to the list of embedded binaries, along with libLLVM.dylib and libclang.dylib.
See `project.pbxproj` in this directory for an example.

Commands in `project.pbxproj`: clang, lli, llvm-link, opt, llvm-nm, llvm-dis

Once you have the binaries inside your app, you need to provide the header files. I copied the ones from the Xcode iPhone SDK into ~/usr/include, and the ones from build_ios/lib/clang/7.0.0/include/ into ~/lib/clang/7.0.0/include/ This will need some thinking.

I welcome all help on this project, including on this README file.

iOS: how to compile a command?
==============================

It's a multi-step process.

1) compile each source file (*.c) using:
clang -S -emit-llvm -I ~/lib/clang/7.0.0/include -I ~/usr/include -Wno-nullability-completeness -D_FORTIFY_SOURCE=0 file.c
(you can place all the options into a config file, and use 'clang --config ~/clang.cfg file.c' instead)

This produces a 'file.ll' file, containing LLVM bitcode for file.c

(if you are compiling packages that use 'configure', you will need to create your own config.h, and add -DHAVE_CONFIG_H)

2) link the files together:
llvm-link -o=executable.bc *.ll

This produces an 'executable.bc' file, containing (binary) LLVM bitcode for all the source files.

3) execute, using the LLVM interpreter:

lli executable.bc

LLI (LLVM Interpreter) can run both a JIT compiler and an interpreter. Currently, the JIT compiler only works if the main application was started by Xcode on your Mac. So the default mode is to run the interpreter (-force-interpreter=true). This is the opposite of the default mode for LLI. If you want to run the JIT compiler, use '-force-interpreter=false'.

The JIT compiler is at least 3 times faster than the interpreter, so it would be great to be able to run it on independent apps.

If it doesn't work:
-------------------

This is a very experimental work. The interpreter, often, does not work. Here are a few of the issues encountered, and how I solved them:

- "Code generator does not support intrinsic function 'llvm.objectsize.i64.pi08'": compile with -D_FORTIFY_SOURCE=0
- crash when running 'bsearch': compile with bsearch.c https://opensource.apple.com/source/xnu/xnu-1228/libsa/bsearch.c
- crash when running 'qsort': compile with qsort.c https://opensource.apple.com/source/xnu/xnu-344/bsd/kern/qsort.c

External functions are called using libFFI, and libFFI has problems with pointer manipulation (that's what happens with bsearch and qsort).

- "Unable to allocate memory for common symbols": (more likely with the JIT) sorry, no ideas.
- "Unknown constant pointer type!": beats me.


LLVM iOS version TODO list:
===========================

X make it easier to add llvm binaries to existing iOS projects, with associated dylibs
X added external functions for exit, print, abort, system, exec... (both interpreter and JIT)
- check that memory is freed when LLVM exits, that all flags are reset
- create a "fake libc" for functions that don't work with FFI (qsort, bsearch,...)
X create static libraries instead of executables
X create frameworks with the static libraries

LLVM iOS version wish list:
===========================

X run lli on a llvm intermediate representation, on an iOS device.
X ...with output on the application screen.
X generate llvm intermediate representation locally on iOS device
X ...and run it using lli
X ...without the need to specify "clang -cc1"
X add libFFI to lli, to load dynamic libraries
X install headers on iOS device, for compilation
- load more dynamic libraries, as needed.

X run lli on binary intermediate representation
X use lli to run a "serious" application (multiple source files, command line
arguments)

- compile libcxx and libcxxabi for iOS as well --> required?