-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sources are #included instead of inlined by default.
- Loading branch information
Showing
8 changed files
with
5,533 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BasedOnStyle: Google |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CXX ?= c++ | ||
|
||
CXXFLAGS := -std=c++11 | ||
CXXFLAGS_OPT := $(CXXFLAGS) -O2 -s | ||
CXXFLAGS_DBG := $(CXXFLAGS) -fsanitize=address -g -O1 -fno-omit-frame-pointer | ||
CXXFLAGS_FASTBUILD := $(CXXFLAGS) -O0 -s | ||
|
||
build/amalgamate: amalgamate.cpp | build | ||
$(CXX) $(CXXFLAGS_FASTBUILD) -o build/amalgamate amalgamate.cpp | ||
|
||
build: | ||
@mkdir build | ||
|
||
clean: | build | ||
rm -rf build | ||
|
||
.PHONY: amalgamate clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# LibSass amalgamation script | ||
|
||
This script concatenates LibSass sources into a single file. | ||
|
||
This reduces single-core compilation time by 50% and the output shared library size by 10%. | ||
|
||
SQLite has a great writeup on amalgamation here: | ||
<https://www.sqlite.org/amalgamation.html>. | ||
|
||
## Options | ||
|
||
* `--inline`. Default: `false`\ | ||
When `true`, all sources are inlined into the amalgam file (including headers.\ | ||
When `false`, the amalgam file instead contains `#include` statements for each `.c,.cpp` file. | ||
* `--root`. Default: `$PWD`.\ | ||
The root directory. | ||
By default, the `src/` subdirectory of root is searched and includes are | ||
resolved relative to it. | ||
* `--out`. Default: `/dev/stdout`.\ | ||
Path to the amalgamated source output. | ||
|
||
## Benchmarks | ||
|
||
With amalgamation: | ||
|
||
~~~bash | ||
rm -f script/amalgamate/build/amalgamate && make clean AMALGAM=1 && \ | ||
time make lib/libsass.so AMALGAM=1 && du -sh lib/libsass.so | ||
~~~ | ||
|
||
Compilation time (1 core): 30s | ||
`lib/libsass.so` size: 3.0M | ||
|
||
These numbers are the same affected for both inline and include-style amalgamation. | ||
|
||
Without amalgamation: | ||
|
||
~~~bash | ||
make clean AMALGAM=0 && time make -j`nproc` lib/libsass.so AMALGAM=0 && du -sh lib/libsass.so | ||
~~~ | ||
|
||
Compilation time (1 core): 60s | ||
Compilation time (8 cores): 16s | ||
`lib/libsass.so` size: 3.3M |
Oops, something went wrong.