| 1 |
You will find detailed installation instructions in the ECL manual |
| 2 |
https://common-lisp.net/project/ecl/static/manual/Building-ECL.html |
| 3 |
If you do not have access to the online version, follow the following recipies. |
| 4 |
|
| 5 |
* Unix and similar platforms. |
| 6 |
1. Type |
| 7 |
./configure --help |
| 8 |
to get a list of the flags with which ECL can be configured. |
| 9 |
2. Enter |
| 10 |
./configure <flags> |
| 11 |
where <flags> is the set of flags you have chosen. |
| 12 |
3. Use "make" followed by "make install" to build and install ECL. |
| 13 |
|
| 14 |
* Windows with Visual Studio C++ 2008 |
| 15 |
1. Open the Visual Studio x86 or x64 native tools command prompt |
| 16 |
2. Enter the msvc directory |
| 17 |
3. Read the file Makefile to find the configuration options. They |
| 18 |
typically have the form ECL_UNICODE=1, ECL_THREADS=1, etc |
| 19 |
4. Enter |
| 20 |
nmake <options> |
| 21 |
where <options> is a set of zero or more of those options |
| 22 |
5. Use "nmake install" to create a directory called "package" with ECL in it. |
| 23 |
6. Move that directory wherever you need. |
| 24 |
|
| 25 |
* Cross-compile for the android platform (from the UNIX machine) |
| 26 |
1. Configure the toolchain (requires android-ndk version 22 or higher, known to work with version 28b) |
| 27 |
and export the necessary paths: |
| 28 |
#+BEGIN_SRC shell-script |
| 29 |
export NDK_PATH=/opt/android-ndk |
| 30 |
export ANDROID_API=23 |
| 31 |
export TOOLCHAIN_PATH=${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64 # use darwin instead of linux if compiling on Mac OS host |
| 32 |
export TARGET=armv7a-linux-androideabi |
| 33 |
#+END_SRC |
| 34 |
2. Build and install the target library |
| 35 |
#+BEGIN_SRC shell-script |
| 36 |
export CC="${TOOLCHAIN_PATH}/bin/clang --target=${TARGET}${ANDROID_API}" |
| 37 |
export LD=${TOOLCHAIN_PATH}/bin/ld |
| 38 |
export AR=${TOOLCHAIN_PATH}/bin/llvm-ar |
| 39 |
export RANLIB=${TOOLCHAIN_PATH}/bin/llvm-ranlib |
| 40 |
export ECL_TO_RUN=/usr/local/bin/ecl |
| 41 |
./configure --host=${TARGET} \ |
| 42 |
--prefix=`pwd`/ecl-android \ |
| 43 |
--disable-c99complex \ |
| 44 |
--with-cross-config=`pwd`/src/util/android-arm.cross_config |
| 45 |
make -j9 |
| 46 |
make install |
| 47 |
#+END_SRC |
| 48 |
3. Library and assets in the ecl-android directory are ready to run on |
| 49 |
the Android system. |
| 50 |
|
| 51 |
|
| 52 |
* Cross-compile for the iOS platform (needs Xcode 11 or higher) |
| 53 |
1. Configure the toolchain |
| 54 |
#+BEGIN_SRC shell-script |
| 55 |
export IOS_VERSION_MIN="8.0" |
| 56 |
export IOS_SDK_DIR="`xcode-select --print-path`/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/" |
| 57 |
|
| 58 |
export CC="clang" |
| 59 |
export CXX="clang++" |
| 60 |
|
| 61 |
export CFLAGS="-arch arm64 -miphoneos-version-min=${IOS_VERSION_MIN} -isysroot ${IOS_SDK_DIR}" |
| 62 |
export CFLAGS="$CFLAGS -pipe -Wno-trigraphs -Wreturn-type -Wunused-variable" |
| 63 |
export CFLAGS="$CFLAGS -fpascal-strings -fasm-blocks -fmessage-length=0 -fvisibility=hidden" |
| 64 |
export CFLAGS="$CFLAGS -O2 -DNO_ASM" |
| 65 |
|
| 66 |
export LD="ld" |
| 67 |
export LDFLAGS="-arch arm64 -pipe -std=c99 -gdwarf-2 -isysroot ${IOS_SDK_DIR}" |
| 68 |
export LIBS="-framework Foundation" |
| 69 |
#+END_SRC |
| 70 |
2. Build and install the target library |
| 71 |
#+BEGIN_SRC shell-script |
| 72 |
export CFLAGS="$CFLAGS -DGC_DISABLE_INCREMENTAL -DECL_RWLOCK" |
| 73 |
export CXXFLAGS="$CFLAGS" |
| 74 |
export ECL_TO_RUN=/usr/local/bin/ecl |
| 75 |
./configure --host=aarch64-apple-darwin \ |
| 76 |
--prefix=`pwd`/ecl-iOS \ |
| 77 |
--disable-c99complex \ |
| 78 |
--disable-shared \ |
| 79 |
--with-cross-config=`pwd`/src/util/iOS-arm64.cross_config |
| 80 |
make -j9 |
| 81 |
make install |
| 82 |
#+END_SRC |
| 83 |
3. Library and assets in the ecl-iOS directory are ready to run on |
| 84 |
the iOS system. |
| 85 |
|
| 86 |
* Cross-compile for the WASM platform (via emscripten) |
| 87 |
|
| 88 |
Emscripten target is a little fickle so keep in mind that: |
| 89 |
|
| 90 |
- shared libraries are supported but come with some drawbacks (e.g. |
| 91 |
increased code size if used together with -sASYNCIFY), therefore the |
| 92 |
build instructions default to disable-shared |
| 93 |
|
| 94 |
- disable-tcp is needed, because accept can't be found (lack of |
| 95 |
-lsockets or something in this spirit?) |
| 96 |
|
| 97 |
- select for interactive streams does not work, because reading operations are |
| 98 |
blocking (as they should be!), so there is no EOF returned -- clear-input will |
| 99 |
hang without a proper file-cnt |
| 100 |
|
| 101 |
- to build emscripten you need to use their SDK that provides the toolchain, and |
| 102 |
set the environment variable EMSDK_PATH |
| 103 |
|
| 104 |
- for the garbage collector to be able to identify roots on the stack, |
| 105 |
you need to pass the -sBINARYEN_EXTRA_PASSES=--spill-pointers option |
| 106 |
to the linker for all of your code that might store pointer on the |
| 107 |
stack (for instance when embedding ECL) |
| 108 |
|
| 109 |
- the optimization level -O0 is used because higher optimization |
| 110 |
levels seem to interfere with the binaryen options needed to get the |
| 111 |
garbage collector to work correctly and tend slow down the program |
| 112 |
(might be worth experimenting with the optimization options) |
| 113 |
|
| 114 |
1. Configure the toolchain |
| 115 |
|
| 116 |
Install the Emscripten SDK using the official instructions: |
| 117 |
|
| 118 |
https://emscripten.org/docs/getting_started/downloads.html |
| 119 |
|
| 120 |
These build instructions were tested against ~emsdk 4.0.12~. If things doesn't |
| 121 |
work try that version instead of ~latest~. |
| 122 |
|
| 123 |
After that activate the toolchain and configure build flags: |
| 124 |
|
| 125 |
#+begin_src shell-script |
| 126 |
source ${EMSDK_PATH}/emsdk_env.sh |
| 127 |
# You may customize various emscripten flags here, i.e: |
| 128 |
# export LDFLAGS="-sASYNCIFY=1" |
| 129 |
#+end_src |
| 130 |
|
| 131 |
2. Build the core environment and install it |
| 132 |
|
| 133 |
#+begin_src shell-script |
| 134 |
export ECL_TO_RUN=/usr/local/bin/ecl |
| 135 |
emconfigure ./configure \ |
| 136 |
--host=wasm32-unknown-emscripten \ |
| 137 |
--build=x86_64-pc-linux-gnu \ |
| 138 |
--with-cross-config=`pwd`/src/util/wasm32-unknown-emscripten.cross_config \ |
| 139 |
--prefix=`pwd`/ecl-emscripten \ |
| 140 |
--disable-shared \ |
| 141 |
--with-tcp=no \ |
| 142 |
--with-cmp=no |
| 143 |
|
| 144 |
emmake make && emmake make install |
| 145 |
|
| 146 |
# some files need to be copied manually |
| 147 |
cp build/bin/ecl.js build/bin/ecl.wasm ecl-emscripten/ |
| 148 |
#+end_src |
| 149 |
|
| 150 |
3. ECL may be hosted on a web page. Assuming that you have quicklisp installed: |
| 151 |
|
| 152 |
#+begin_src shell-script |
| 153 |
export WEBSERVER=`pwd`/src/util/webserver.lisp |
| 154 |
pushd ecl-emscripten/ |
| 155 |
lisp --load $WEBSERVER |
| 156 |
# After the server is loaded run: |
| 157 |
# firefox localhost:8888/ecl.html |
| 158 |
popd |
| 159 |
#+end_src |
| 160 |
|
| 161 |
If the output does not show on the webpage then open the javascript console. |
| 162 |
This is a default html website produced by emscripten. |
| 163 |
|
| 164 |
4. Build an external program linked against libecl.a |
| 165 |
|
| 166 |
The default stack size proposed by emscripten is 64KB. This is too little for |
| 167 |
ECL, so when you build a program that is linked against libecl.a, then it is |
| 168 |
imoprtant to specify a different size. For example: |
| 169 |
|
| 170 |
#+begin_src shell-script |
| 171 |
emcc program.c -sSTACK_SIZE=1048576 lib/*.a -I./include -o program.o |
| 172 |
#+end_src |
| 173 |
|
| 174 |
* Build using Cosmopolitan toolchain (experimental) |
| 175 |
|
| 176 |
Binaries built with cosmopolitan toolchain can be executed on numerous platforms |
| 177 |
without changes. An inititial ECL port has been completed. |
| 178 |
|
| 179 |
1. Download cosmopolitan toolchain and activate it |
| 180 |
|
| 181 |
Instructions for downloading the toolchain are available in its [[https://github.com/jart/cosmopolitan/blob/master/README.md ][repository]]. |
| 182 |
For example: |
| 183 |
|
| 184 |
#+begin_src sh |
| 185 |
mkdir cosmocc |
| 186 |
pushd cosmocc |
| 187 |
curl -o https://cosmo.zip/pub/cosmocc/cosmocc.zip |
| 188 |
unzip *zip |
| 189 |
bin/make --version # sanity test |
| 190 |
export PATH="`pwd`/bin:${PATH}" |
| 191 |
export CC=x86_64-unknown-cosmo-cc |
| 192 |
export CXX=x86_64-unknown-cosmo-c++ |
| 193 |
popd |
| 194 |
#+end_src |
| 195 |
|
| 196 |
2. Build ECL |
| 197 |
|
| 198 |
#+begin_src sh |
| 199 |
LSP_FEATURES=":cosmo" ./configure --disable-shared --prefix=/tmp/cosmo-cl |
| 200 |
make -j15 |
| 201 |
make install |
| 202 |
# make check |
| 203 |
#+end_src |
| 204 |
|
| 205 |
- The platform is reported in *FEATURES* as :COSMO and as :LINUX |
| 206 |
- make check will fail because libc segfaults when using fenv.h |
| 207 |
|
| 208 |
This platform is not upstreamed yet in libgc, so it may be necessary to add the |
| 209 |
following code to the file gcconfig.h: |
| 210 |
|
| 211 |
#+begin_src c |
| 212 |
# if defined(__COSMOPOLITAN__) |
| 213 |
# if defined(__x86_64__) |
| 214 |
# define mach_type_known |
| 215 |
# define X86_64 |
| 216 |
# define LINUX // optional? |
| 217 |
# elif defined(__aarch64__) |
| 218 |
# define mach_type_known |
| 219 |
# define AARCH64 |
| 220 |
# define LINUX // optional? |
| 221 |
# endif |
| 222 |
# endif |
| 223 |
#+end_src |
| 224 |
|
| 225 |
For details see: https://github.com/jart/cosmopolitan/issues/939. |
| 226 |
|
| 227 |
Cosmopolitan condition variables can't be used with mutexes that are not |
| 228 |
initialized as PTHREAD_MUTEX_NORMAL. That means that recursive locks and |
| 229 |
deterministic deadlock detection are not supported on this platform. |
| 230 |
|
| 231 |
Moreover floating point exception handling is not working and it is libc issue |
| 232 |
that manifests itself with segfaults. |