Skip to content

Commit 7f31b07

Browse files
committed
Statically link sundown to librustdoc
Closes #10103
1 parent 2b9c774 commit 7f31b07

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

mk/rt.mk

+28-10
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,7 @@ RUNTIME_CXXS_$(1)_$(2) := \
9292
rt/rust_android_dummy.cpp \
9393
rt/rust_test_helpers.cpp
9494

95-
RUNTIME_CS_$(1)_$(2) := rt/sundown/src/autolink.c \
96-
rt/sundown/src/buffer.c \
97-
rt/sundown/src/stack.c \
98-
rt/sundown/src/markdown.c \
99-
rt/sundown/html/houdini_href_e.c \
100-
rt/sundown/html/houdini_html_e.c \
101-
rt/sundown/html/html_smartypants.c \
102-
rt/sundown/html/html.c
95+
RUNTIME_CS_$(1)_$(2) :=
10396

10497
RUNTIME_S_$(1)_$(2) := rt/arch/$$(HOST_$(1))/_context.S \
10598
rt/arch/$$(HOST_$(1))/record_sp.S
@@ -109,8 +102,6 @@ RT_BUILD_DIR_$(1)_$(2) := $$(RT_OUTPUT_DIR_$(1))/stage$(2)
109102
RUNTIME_DEF_$(1)_$(2) := $$(RT_OUTPUT_DIR_$(1))/rustrt$$(CFG_DEF_SUFFIX_$(1))
110103
RUNTIME_INCS_$(1)_$(2) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
111104
-I $$(S)src/rt/arch/$$(HOST_$(1)) \
112-
-I $$(S)src/rt/sundown/src \
113-
-I $$(S)src/rt/sundown/html \
114105
-I $$(S)src/libuv/include
115106
RUNTIME_OBJS_$(1)_$(2) := $$(RUNTIME_CXXS_$(1)_$(2):rt/%.cpp=$$(RT_BUILD_DIR_$(1)_$(2))/%.o) \
116107
$$(RUNTIME_CS_$(1)_$(2):rt/%.c=$$(RT_BUILD_DIR_$(1)_$(2))/%.o) \
@@ -242,6 +233,33 @@ $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1))
242233
NO_LOAD="$$(LIBUV_NO_LOAD)" \
243234
V=$$(VERBOSE)
244235
endif
236+
237+
SUNDOWN_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),sundown)
238+
SUNDOWN_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/sundown
239+
SUNDOWN_LIB_$(1) := $$(SUNDOWN_DIR_$(1))/$$(SUNDOWN_NAME_$(1))
240+
241+
SUNDOWN_CS_$(1) := rt/sundown/src/autolink.c \
242+
rt/sundown/src/buffer.c \
243+
rt/sundown/src/stack.c \
244+
rt/sundown/src/markdown.c \
245+
rt/sundown/html/houdini_href_e.c \
246+
rt/sundown/html/houdini_html_e.c \
247+
rt/sundown/html/html_smartypants.c \
248+
rt/sundown/html/html.c
249+
250+
SUNDOWN_OBJS_$(1) := $$(SUNDOWN_CS_$(1):rt/%.c=$$(SUNDOWN_DIR_$(1))/%.o)
251+
252+
$$(SUNDOWN_DIR_$(1))/%.o: rt/%.c
253+
@$$(call E, compile: $$@)
254+
@mkdir -p $$(@D)
255+
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, \
256+
-I $$(S)src/rt/sundown/src -I $$(S)src/rt/sundown/html \
257+
$$(RUNTIME_CFLAGS_$(1))) $$<
258+
259+
$$(SUNDOWN_LIB_$(1)): $$(SUNDOWN_OBJS_$(1))
260+
@$$(call E, link: $$@)
261+
$$(Q)$$(AR_$(1)) rcs $$@ $$^
262+
245263
endef
246264

247265
# Instantiate template for all stages/targets

mk/tools.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTDOC_$(4)): \
5757
$$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS) \
5858
$$(SREQ$(1)_T_$(4)_H_$(3)) \
5959
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTC_$(4)) \
60+
$$(SUNDOWN_LIB_$(4)) \
6061
| $$(TLIB$(1)_T_$(4)_H_$(3))/
6162
@$$(call E, compile_and_link: $$@)
6263
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTDOC_GLOB_$(4)),$$(notdir $$@))
63-
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
64+
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) \
65+
-L $$(SUNDOWN_DIR_$(4)) --out-dir $$(@D) $$< && touch $$@
6466
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTDOC_GLOB_$(4)),$$(notdir $$@))
6567

6668
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X_$(4)): \

src/librustdoc/html/markdown.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct buf {
6969
}
7070

7171
// sundown FFI
72+
#[link_args = "-lsundown"]
7273
extern {
7374
fn sdhtml_renderer(callbacks: *sd_callbacks,
7475
options_ptr: *html_renderopt,

src/rt/rustrt.def.in

-6
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,6 @@ rust_uv_pipe_init
183183
rust_uv_signal_init
184184
rust_uv_signal_start
185185
rust_uv_signal_stop
186-
sdhtml_renderer
187-
sd_markdown_new
188-
sd_markdown_render
189-
sd_markdown_free
190-
bufrelease
191-
bufnew
192186
rust_take_dlerror_lock
193187
rust_drop_dlerror_lock
194188
rust_uv_pipe_open

0 commit comments

Comments
 (0)