Statically link libuv to librustuv

Similarly to the previous commit, libuv is only used by this library, so there's
no need for it to be linked into librustrt and available to all crates by
default.
This commit is contained in:
Alex Crichton 2013-10-30 23:57:27 -07:00
parent 7f31b079e5
commit 0ce1b2f04d
7 changed files with 52 additions and 127 deletions

View File

@ -625,10 +625,10 @@ config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
# new definitions), make sure definitions always precede their uses,
# especially for the dependency lists of recipes.
include $(CFG_SRC_DIR)mk/rt.mk
include $(CFG_SRC_DIR)mk/target.mk
include $(CFG_SRC_DIR)mk/host.mk
include $(CFG_SRC_DIR)mk/stage0.mk
include $(CFG_SRC_DIR)mk/rt.mk
include $(CFG_SRC_DIR)mk/rustllvm.mk
include $(CFG_SRC_DIR)mk/tools.mk
include $(CFG_SRC_DIR)mk/docs.mk

View File

@ -87,7 +87,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
rt/sync/rust_thread.cpp \
rt/rust_builtin.cpp \
rt/rust_upcall.cpp \
rt/rust_uv.cpp \
rt/miniz.cpp \
rt/rust_android_dummy.cpp \
rt/rust_test_helpers.cpp
@ -101,8 +100,7 @@ RT_BUILD_DIR_$(1)_$(2) := $$(RT_OUTPUT_DIR_$(1))/stage$(2)
RUNTIME_DEF_$(1)_$(2) := $$(RT_OUTPUT_DIR_$(1))/rustrt$$(CFG_DEF_SUFFIX_$(1))
RUNTIME_INCS_$(1)_$(2) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
-I $$(S)src/rt/arch/$$(HOST_$(1)) \
-I $$(S)src/libuv/include
-I $$(S)src/rt/arch/$$(HOST_$(1))
RUNTIME_OBJS_$(1)_$(2) := $$(RUNTIME_CXXS_$(1)_$(2):rt/%.cpp=$$(RT_BUILD_DIR_$(1)_$(2))/%.o) \
$$(RUNTIME_CS_$(1)_$(2):rt/%.c=$$(RT_BUILD_DIR_$(1)_$(2))/%.o) \
$$(RUNTIME_S_$(1)_$(2):rt/%.S=$$(RT_BUILD_DIR_$(1)_$(2))/%.o)
@ -131,10 +129,9 @@ $$(RT_BUILD_DIR_$(1)_$(2))/arch/$$(HOST_$(1))/libmorestack.a: $$(MORESTACK_OBJS_
$$(Q)$(AR_$(1)) rcs $$@ $$^
$$(RT_BUILD_DIR_$(1)_$(2))/$(CFG_RUNTIME_$(1)): $$(RUNTIME_OBJS_$(1)_$(2)) $$(MKFILE_DEPS) \
$$(RUNTIME_DEF_$(1)_$(2)) $$(LIBUV_LIB_$(1))
$$(RUNTIME_DEF_$(1)_$(2))
@$$(call E, link: $$@)
$$(Q)$$(call CFG_LINK_CXX_$(1),$$@, $$(RUNTIME_OBJS_$(1)_$(2)) \
$$(LIBUV_LIB_$(1)) \
$$(CFG_LIBUV_LINK_FLAGS_$(1)),$$(RUNTIME_DEF_$(1)_$(2)),$$(CFG_RUNTIME_$(1)))
# These could go in rt.mk or rustllvm.mk, they're needed for both.
@ -234,6 +231,27 @@ $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1))
V=$$(VERBOSE)
endif
# libuv support functionality (extra C/C++ that we need to use libuv)
UV_SUPPORT_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),uv_support)
UV_SUPPORT_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/uv_support
UV_SUPPORT_LIB_$(1) := $$(UV_SUPPORT_DIR_$(1))/$$(UV_SUPPORT_NAME_$(1))
UV_SUPPORT_CS_$(1) := rt/rust_uv.cpp
UV_SUPPORT_OBJS_$(1) := $$(UV_SUPPORT_CS_$(1):rt/%.cpp=$$(UV_SUPPORT_DIR_$(1))/%.o)
$$(UV_SUPPORT_DIR_$(1))/%.o: rt/%.cpp
@$$(call E, compile: $$@)
@mkdir -p $$(@D)
$$(Q)$$(call CFG_COMPILE_CXX_$(1), $$@, \
-I $$(S)src/libuv/include \
$$(RUNTIME_CFLAGS_$(1))) $$<
$$(UV_SUPPORT_LIB_$(1)): $$(UV_SUPPORT_OBJS_$(1))
@$$(call E, link: $$@)
$$(Q)$$(AR_$(1)) rcs $$@ $$^
# sundown markdown library (used by librustdoc)
SUNDOWN_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),sundown)
SUNDOWN_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/sundown
SUNDOWN_LIB_$(1) := $$(SUNDOWN_DIR_$(1))/$$(SUNDOWN_NAME_$(1))

View File

@ -77,10 +77,15 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2)): \
$$(LIBRUSTUV_CRATE) $$(LIBRUSTUV_INPUTS) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
$$(LIBUV_LIB_$(2)) \
$$(UV_SUPPORT_LIB_$(2)) \
| $$(TLIB$(1)_T_$(2)_H_$(3))/
@$$(call E, compile_and_link: $$@)
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
-L $$(UV_SUPPORT_DIR_$(2)) \
-L $$(dir $$(LIBUV_LIB_$(2))) \
--out-dir $$(@D) $$< && touch $$@
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
@ -117,13 +122,16 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
# NOTE: after the next snapshot remove these '-L' flags
$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \
$$(DRIVER_CRATE) \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)) \
| $$(TBIN$(1)_T_$(2)_H_$(3))/
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$<
$$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$< \
-L $$(UV_SUPPORT_DIR_$(2)) \
-L $$(dir $$(LIBUV_LIB_$(2)))
ifdef CFG_ENABLE_PAX_FLAGS
@$$(call E, apply PaX flags: $$@)
@"$(CFG_PAXCTL)" -cm "$$@"

View File

@ -358,7 +358,9 @@ $(3)/stage$(1)/test/rustuvtest-$(2)$$(X_$(2)): \
$$(LIBRUSTUV_CRATE) $$(LIBRUSTUV_INPUTS) \
$$(STDTESTDEP_$(1)_$(2)_$(3))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
-L $$(UV_SUPPORT_DIR_$(2)) \
-L $$(dir $$(LIBUV_LIB_$(2)))
$(3)/stage$(1)/test/syntaxtest-$(2)$$(X_$(2)): \
$$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
@ -392,7 +394,8 @@ $(3)/stage$(1)/test/rustdoctest-$(2)$$(X_$(2)): \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
-L $$(SUNDOWN_DIR_$(2))
endef

View File

@ -304,8 +304,7 @@ pub mod llvm {
use super::debuginfo::*;
use std::libc::{c_char, c_int, c_longlong, c_ushort, c_uint, c_ulonglong};
#[link_args = "-Lrustllvm -lrustllvm"]
#[link_name = "rustllvm"]
#[link_args = "-lrustllvm"]
extern {
/* Create and destroy contexts. */
pub fn LLVMContextCreate() -> ContextRef;

View File

@ -1003,6 +1003,8 @@ pub struct uv_err_data {
err_msg: ~str,
}
// uv_support is the result of compiling rust_uv.cpp
#[link_args = "-luv_support -luv"]
extern {
fn rust_uv_handle_size(type_: uintptr_t) -> size_t;
@ -1172,3 +1174,13 @@ extern {
signum: c_int) -> c_int;
fn rust_uv_signal_stop(handle: *uv_signal_t) -> c_int;
}
// libuv requires various system libraries to successfully link on some
// platforms
#[cfg(target_os = "linux")]
#[link_args = "-lpthread"]
extern {}
#[cfg(target_os = "win32")]
#[link_args = "-lWs2_32 -lpsapi -liphlpapi"]
extern {}

View File

@ -26,92 +26,6 @@ rust_win32_rand_gen
rust_win32_rand_release
upcall_rust_personality
upcall_reset_stack_limit
rust_uv_loop_new
rust_uv_loop_delete
rust_uv_walk
rust_uv_loop_set_data
rust_uv_run
rust_uv_close
rust_uv_async_send
rust_uv_async_init
rust_uv_timer_init
rust_uv_timer_start
rust_uv_timer_stop
rust_uv_tcp_init
rust_uv_buf_init
rust_uv_strerror
rust_uv_err_name
rust_uv_ip4_addr
rust_uv_ip4_name
rust_uv_ip6_addr
rust_uv_ip6_name
rust_uv_tcp_connect
rust_uv_tcp_bind
rust_uv_tcp_connect6
rust_uv_tcp_bind6
rust_uv_tcp_getsockname
rust_uv_tcp_nodelay
rust_uv_tcp_keepalive
rust_uv_tcp_simultaneous_accepts
rust_uv_udp_init
rust_uv_udp_bind
rust_uv_udp_bind6
rust_uv_udp_send
rust_uv_udp_send6
rust_uv_udp_recv_start
rust_uv_udp_recv_stop
rust_uv_get_udp_handle_from_send_req
rust_uv_udp_getsockname
rust_uv_udp_set_membership
rust_uv_udp_set_multicast_loop
rust_uv_udp_set_multicast_ttl
rust_uv_udp_set_ttl
rust_uv_udp_set_broadcast
rust_uv_is_ipv4_sockaddr
rust_uv_is_ipv6_sockaddr
rust_uv_malloc_sockaddr_storage
rust_uv_free_sockaddr_storage
rust_uv_listen
rust_uv_accept
rust_uv_write
rust_uv_read_start
rust_uv_read_stop
rust_uv_is_ipv4_addrinfo
rust_uv_is_ipv6_addrinfo
rust_uv_get_next_addrinfo
rust_uv_addrinfo_as_sockaddr_in
rust_uv_addrinfo_as_sockaddr_in6
rust_uv_get_stream_handle_from_connect_req
rust_uv_get_stream_handle_from_write_req
rust_uv_get_loop_for_uv_handle
rust_uv_get_data_for_uv_loop
rust_uv_set_data_for_uv_loop
rust_uv_get_data_for_uv_handle
rust_uv_set_data_for_uv_handle
rust_uv_get_data_for_req
rust_uv_set_data_for_req
rust_uv_get_base_from_buf
rust_uv_get_len_from_buf
rust_uv_getaddrinfo
rust_uv_freeaddrinfo
rust_uv_idle_init
rust_uv_idle_start
rust_uv_idle_stop
rust_uv_fs_open
rust_uv_fs_unlink
rust_uv_fs_write
rust_uv_fs_read
rust_uv_fs_close
rust_uv_get_result_from_fs_req
rust_uv_get_ptr_from_fs_req
rust_uv_get_loop_from_fs_req
rust_uv_fs_stat
rust_uv_fs_fstat
rust_uv_fs_req_cleanup
rust_uv_populate_uv_stat
rust_uv_fs_mkdir
rust_uv_fs_rmdir
rust_uv_fs_readdir
rust_dbg_lock_create
rust_dbg_lock_destroy
rust_dbg_lock_lock
@ -128,9 +42,6 @@ rust_signal_little_lock
rust_wait_little_lock
tdefl_compress_mem_to_heap
tinfl_decompress_mem_to_heap
rust_uv_ip4_port
rust_uv_ip6_port
rust_uv_tcp_getpeername
rust_raw_thread_start
rust_raw_thread_join
rust_raw_thread_delete
@ -150,14 +61,6 @@ rust_dbg_extern_return_TwoU32s
rust_dbg_extern_return_TwoU64s
rust_dbg_extern_identity_double
rust_dbg_extern_identity_u8
rust_uv_handle_size
rust_uv_req_size
rust_uv_handle_type_max
rust_uv_req_type_max
rust_uv_ip4_addrp
rust_uv_ip6_addrp
rust_uv_free_ip4_addr
rust_uv_free_ip6_addr
rust_initialize_rt_tls_key
rust_dbg_next_port
rust_try
@ -172,23 +75,5 @@ rust_get_global_args_ptr
rust_take_global_args_lock
rust_drop_global_args_lock
rust_get_test_int
rust_uv_get_loop_from_getaddrinfo_req
rust_uv_spawn
rust_uv_process_kill
rust_set_stdio_container_flags
rust_set_stdio_container_fd
rust_set_stdio_container_stream
rust_uv_process_pid
rust_uv_pipe_init
rust_uv_signal_init
rust_uv_signal_start
rust_uv_signal_stop
rust_take_dlerror_lock
rust_drop_dlerror_lock
rust_uv_pipe_open
rust_uv_pipe_bind
rust_uv_pipe_connect
rust_uv_tty_init
rust_uv_tty_set_mode
rust_uv_tty_get_winsize
rust_uv_guess_handle