]> git.lizzy.rs Git - rust.git/commitdiff
Statically link libuv to librustuv
authorAlex Crichton <alex@alexcrichton.com>
Thu, 31 Oct 2013 06:57:27 +0000 (23:57 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 3 Nov 2013 04:28:17 +0000 (21:28 -0700)
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.

Makefile.in
mk/rt.mk
mk/target.mk
mk/tests.mk
src/librustc/lib/llvm.rs
src/librustuv/uvll.rs
src/rt/rustrt.def.in

index b4730a7952f64dc832279501c2bac2728e947a5a..28969e4a52623d0847b1413c9d90cc01295cafa7 100644 (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
index a7f09e63ce0a32d7b19ed230a3ac9af35a2a0775..d51b09b56dafa4516f2b872c0349e6265fd45ab1 100644 (file)
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -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))
index ac95b2f5c66852bde307ed55218aa5745229d835..f7d8ec83a5a17cc70775b9bd923d17de066aa14a 100644 (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 "$$@"
index 02242897d3557a6e9c6a3a97ebed8ba8ebad26a9..eabb5f535e61d900ec9fd2dcff0aa3730f09cf1a 100644 (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
 
index 4eb8a0b8fa644c6d924082fab3ce4b1f621064be..e152d009050c858dbe74144e746842c9171b576c 100644 (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;
index f80178cfa4c620b84287d16bf6c1ce71ee1d5c0a..9e86ab11286e4d049f9690b97609aadbcb3dfe6c 100644 (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 @@ fn rust_uv_signal_start(handle: *uv_signal_t,
                             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 {}
index 01b3c97aa1c8e4b1cd47669731525b3c045e91fb..275966583d92ce45385aa287532cdb8cccf5e9c7 100644 (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