Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc/guide/build: use optimized-static-exe for release mode. #818

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions doc/guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ $ ./build.ss
## Intermediate build scripts

Here is a build script that uses an environment variable to determine
whether to build a fully static binary or a normally linked binary:
whether to build an optimized fully static binary or a normally linked binary:

```bash
$ cat build.ss
#!/usr/bin/env gxi
(import :std/build-script)
(defbuild-script
`("util"
,(if (getenv "BUILD_STATIC_EXE" #f) '(static-exe: "hello") '(exe: "hello"))))
,(if (getenv "BUILD_RELEASE" #f) '(optimized-static-exe: "hello") '(exe: "hello"))))
```

If you are in your development environment and building executables for your host, then you can just invoke it as
Expand All @@ -73,7 +73,15 @@ If you are in your development environment and building executables for your hos

On the other hand, if you are building inside a docker container that
supports fully static binaries (say alpine or void linux), you can
just use the following to build a fully static binary:
just use the following to build an optimized fully static binary:
```bash
BUILD_STATIC_EXE=t ./build.ss
BUILD_RELEASE=t ./build.ss
```

::: tip Note
You may need to pass some linker flags in your build spec, using
`(optimized-static-exe: <module> "-ld-options" "...")`. This might be
necessary because the compiler cannot tell what the tree shaker will
eliminate and thus it is not prudent to automatically link all stdlib
foreign dependencies.
:::