Skip to content

Commit 2b8c6b1

Browse files
authored
chore: Rework the shared-builtins target to produce a single static archive (#646)
1 parent 8328add commit 2b8c6b1

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

runtime/js-compute-runtime/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
!/host_interface/component/fastly_world.o
66
/js-compute-runtime*.wasm
77
/build
8-
/shared

runtime/js-compute-runtime/Makefile

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,19 +338,28 @@ $(OBJ_DIR)/js-compute-runtime-component.wasm: $(OBJ_DIR)/host_interface/componen
338338

339339
# Shared builtins build ########################################################
340340

341-
shared-builtins: shared/builtins.a shared/librust_url.a shared/librust_encoding.a
341+
.PHONY: shared-builtins
342+
shared-builtins: shared.a
342343

343-
shared/builtins.a: $(OBJ_DIR)/builtins/shared/*.o
344-
shared/builtins.a: $(OBJ_DIR)/builtin.o
345-
shared/builtins.a: $(OBJ_DIR)/core/encode.o
346-
shared/builtins.a: | shared
347-
$(call cmd,wasi_ar,$^)
348-
349-
shared/librust_url.a: $(RUST_URL_LIB) | shared
344+
.PHONY: shared.a
345+
shared.a: $(OBJ_DIR)/shared.a
350346
$(call cmd,cp,$@)
351347

352-
shared/librust_encoding.a: $(RUST_ENCODING_LIB) | shared
353-
$(call cmd,cp,$@)
348+
extract_lib = $(call cmd_format,WASI_AR [x],$2) $(WASI_AR) -x --output $1 $2
349+
350+
$(OBJ_DIR)/shared: $(OBJ_DIR)/builtins.a $(RUST_URL_LIB) $(RUST_ENCODING_LIB)
351+
$(call cmd,mkdir,$@)
352+
$(call extract_lib,$(OBJ_DIR)/shared,$(OBJ_DIR)/builtins.a)
353+
$(call extract_lib,$(OBJ_DIR)/shared,$(RUST_URL_LIB))
354+
$(call extract_lib,$(OBJ_DIR)/shared,$(RUST_ENCODING_LIB))
355+
356+
$(OBJ_DIR)/shared.a: | $(OBJ_DIR)/shared
357+
$(call cmd,wasi_ar,$(wildcard $(OBJ_DIR)/shared/*.o))
358+
359+
$(OBJ_DIR)/builtins.a: $(filter $(OBJ_DIR)/builtins/shared/%.o,$(FSM_OBJ))
360+
$(OBJ_DIR)/builtins.a: $(OBJ_DIR)/builtin.o
361+
$(OBJ_DIR)/builtins.a: $(OBJ_DIR)/core/encode.o
362+
$(call cmd,wasi_ar,$^)
354363

355364
# These two rules copy the built artifacts into the $(FSM_SRC) directory, and
356365
# are both marked phony as we need to do the right thing when running the

runtime/js-compute-runtime/mk/commands.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Q := @
88
quiet_flag = $1
99

1010
# Convenience macro for calling known commands with a nicer output format.
11-
cmd = $(call cmd_format,$(cmd_$1_name),$2)$(call cmd_$1,$2)
11+
cmd = $(call cmd_format,$(cmd_$1_name),$@)$(call cmd_$1,$2)
1212

1313
# Strip off the js-compute-runtime root from a path.
1414
without_root = $(subst $(FSM_SRC)/,,$1)
@@ -39,7 +39,7 @@ cmd_wget_name := WGET
3939
cmd_wget = wget $(URL) $(call quiet_flag,--quiet) -O $1
4040

4141
cmd_wasi_ar_name := WASI_AR
42-
cmd_wasi_ar = $(WASI_AR) rcs $@ $^
42+
cmd_wasi_ar = $(WASI_AR) rcs $@ $1
4343

4444
cmd_wasi_cxx_name := WASI_CXX
4545
cmd_wasi_cxx = $(WASI_CXX) $(CXX_FLAGS) $(OPT_FLAGS) $(INCLUDES) $(DEFINES) -MMD -MP -c -o $1 $<

0 commit comments

Comments
 (0)