Skip to content

Commit 7e09615

Browse files
authored
Upgrade to Sqlite 3.36.0 (#478)
* Run `npm ci` automatically after the devcontainer is created. This reduces the chance that another dev will forget to do this. * Upgrade to Emscripten 2.0.29 Changes required: * Defined EM_NODE_JS environment variable to get rid of a warning that appears if the NODE environment variable is set, but EM_NODE_JS is not. * EXTRA_EXPORTED_RUNTIME_METHODS is now EXPORTED_RUNTIME_METHODS * No longer pass the `-s LINKABLE=1` option to emcc when compiling. (This is a linktime setting and emcc warns about not using a linktime setting when compiling now). * Upgrade to Sqlite 3.36.0 Sqlite now publishes the hash as a SHA3 instead of SHA1, necessitating the installation of the sha3sum command.
1 parent 5682241 commit 7e09615

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

.devcontainer/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
2424
# Install EMSDK to /emsdk just like the EMSDK Dockerfile: https://github.com/emscripten-core/emsdk/blob/master/docker/Dockerfile
2525
ENV EMSDK /emsdk
2626
# We pin EMSDK to 2.0.15 rather than 'latest' so that everyone is using the same compiler version
27-
ENV EMSCRIPTEN_VERSION 2.0.15
27+
ENV EMSCRIPTEN_VERSION 2.0.29
2828

2929
RUN git clone https://github.com/emscripten-core/emsdk.git $EMSDK
3030

@@ -36,7 +36,7 @@ RUN echo "## Install Emscripten" \
3636
# Copied directly from https://github.com/emscripten-core/emsdk/blob/master/docker/Dockerfile
3737
RUN cd ${EMSDK} \
3838
&& echo "## Generate standard configuration" \
39-
&& ./emsdk activate $EMSCRIPTEN_VERSION \
39+
&& ./emsdk activate ${EMSCRIPTEN_VERSION} \
4040
&& chmod 777 ${EMSDK}/upstream/emscripten \
4141
&& chmod -R 777 ${EMSDK}/upstream/emscripten/cache \
4242
&& echo "int main() { return 0; }" > hello.c \
@@ -47,6 +47,7 @@ RUN cd ${EMSDK} \
4747
ENV PATH $EMSDK:$EMSDK/upstream/emscripten/:$PATH
4848

4949
# Cleanup Emscripten installation and strip some symbols
50+
# Copied directly from https://github.com/emscripten-core/emsdk/blob/master/docker/Dockerfile
5051
RUN echo "## Aggressive optimization: Remove debug symbols" \
5152
&& cd ${EMSDK} && . ./emsdk_env.sh \
5253
# Remove debugging symbols from embedded node (extra 7MB)
@@ -60,6 +61,12 @@ RUN echo "## Aggressive optimization: Remove debug symbols" \
6061
&& echo "## Done"
6162

6263
RUN echo ". /emsdk/emsdk_env.sh" >> /etc/bash.bashrc
64+
# We must set the EM_NODE_JS environment variable for a somewhat silly reason
65+
# We run our build scripts with `npm run`, which sets the NODE environment variable as it runs.
66+
# The EMSDK picks up on that environment variable and gives a deprecation warning: warning: honoring legacy environment variable `NODE`. Please switch to using `EM_NODE_JS` instead`
67+
# So, we are going to put this environment variable here explicitly to avoid the deprecation warning.
68+
RUN echo 'export EM_NODE_JS="$EMSDK_NODE"' >> /etc/bash.bashrc
69+
6370
# END EMSDK
6471
# --------------------------------------------------------------------
6572

@@ -117,6 +124,9 @@ RUN apt-get update \
117124
wget \
118125
xdg-utils
119126

127+
# Installs the command "sha3sum", which is used check the download integrity of sqlite source.
128+
RUN apt-get install -y libdigest-sha3-perl
129+
120130
# We set this env variable (RUN_WORKER_TEST_WITHOUT_PUPPETEER_SANDBOX=1) this to tell our sql.js test harness to run Puppeteer without the sandbox.
121131
# Otherwise, when we instantiate Puppeteer, we get this error:
122132
# Puppeteer can't start due to a sandbox error. (Details follow.)

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
// Use 'forwardPorts' to make a list of ports inside the container available locally.
1919
// "forwardPorts": [],
2020
// Use 'postCreateCommand' to run commands after the container is created.
21-
// "postCreateCommand": "yarn install",
21+
// We use `npm ci` instead of `npm install` because we want to respect the lockfile and ONLY the lockfile.
22+
// That way, our devcontainer is more reproducible. --Taytay
23+
"postCreateCommand": "npm ci",
2224
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
2325
"remoteUser": "node"
2426
}

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
# I got this handy makefile syntax from : https://github.com/mandel59/sqlite-wasm (MIT License) Credited in LICENSE
88
# To use another version of Sqlite, visit https://www.sqlite.org/download.html and copy the appropriate values here:
9-
SQLITE_AMALGAMATION = sqlite-amalgamation-3350000
10-
SQLITE_AMALGAMATION_ZIP_URL = https://www.sqlite.org/2021/sqlite-amalgamation-3350000.zip
11-
SQLITE_AMALGAMATION_ZIP_SHA1 = ba64bad885c9f51df765a9624700747e7bf21b79
9+
SQLITE_AMALGAMATION = sqlite-amalgamation-3360000
10+
SQLITE_AMALGAMATION_ZIP_URL = https://www.sqlite.org/2021/sqlite-amalgamation-3360000.zip
11+
SQLITE_AMALGAMATION_ZIP_SHA3 = d25609210ec93b3c8c7da66a03cf82e2c9868cfbd2d7d866982861855e96f972
1212

1313
# Note that extension-functions.c hasn't been updated since 2010-02-06, so likely doesn't need to be updated
1414
EXTENSION_FUNCTIONS = extension-functions.c
@@ -35,7 +35,7 @@ EMFLAGS = \
3535
-s RESERVED_FUNCTION_POINTERS=64 \
3636
-s ALLOW_TABLE_GROWTH=1 \
3737
-s EXPORTED_FUNCTIONS=@src/exported_functions.json \
38-
-s EXTRA_EXPORTED_RUNTIME_METHODS=@src/exported_runtime_methods.json \
38+
-s EXPORTED_RUNTIME_METHODS=@src/exported_runtime_methods.json \
3939
-s SINGLE_FILE=0 \
4040
-s NODEJS_CATCH_EXIT=0 \
4141
-s NODEJS_CATCH_REJECTION=0
@@ -154,7 +154,7 @@ out/sqlite3.bc: sqlite-src/$(SQLITE_AMALGAMATION)
154154
out/extension-functions.bc: sqlite-src/$(SQLITE_AMALGAMATION)
155155
mkdir -p out
156156
# Generate llvm bitcode
157-
$(EMCC) $(CFLAGS) -s LINKABLE=1 -c sqlite-src/$(SQLITE_AMALGAMATION)/extension-functions.c -o $@
157+
$(EMCC) $(CFLAGS) -c sqlite-src/$(SQLITE_AMALGAMATION)/extension-functions.c -o $@
158158

159159
# TODO: This target appears to be unused. If we re-instatate it, we'll need to add more files inside of the JS folder
160160
# module.tar.gz: test package.json AUTHORS README.md dist/sql-asm.js
@@ -175,8 +175,8 @@ sqlite-src: sqlite-src/$(SQLITE_AMALGAMATION) sqlite-src/$(SQLITE_AMALGAMATION)/
175175

176176
sqlite-src/$(SQLITE_AMALGAMATION): cache/$(SQLITE_AMALGAMATION).zip sqlite-src/$(SQLITE_AMALGAMATION)/$(EXTENSION_FUNCTIONS)
177177
mkdir -p sqlite-src/$(SQLITE_AMALGAMATION)
178-
echo '$(SQLITE_AMALGAMATION_ZIP_SHA1) ./cache/$(SQLITE_AMALGAMATION).zip' > cache/check.txt
179-
sha1sum -c cache/check.txt
178+
echo '$(SQLITE_AMALGAMATION_ZIP_SHA3) ./cache/$(SQLITE_AMALGAMATION).zip' > cache/check.txt
179+
sha3sum -c cache/check.txt
180180
# We don't delete the sqlite_amalgamation folder. That's a job for clean
181181
# Also, the extension functions get copied here, and if we get the order of these steps wrong,
182182
# this step could remove the extension functions, and that's not what we want

0 commit comments

Comments
 (0)