Auto merge of #28421 - alexcrichton:msvc-rmake, r=alexcrichton
Work carried over from #27938
This commit is contained in:
commit
8ea2198215
|
@ -1046,6 +1046,10 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \
|
||||||
$$(RMAKE_TESTS:%=$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok)
|
$$(RMAKE_TESTS:%=$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok)
|
||||||
@touch $$@
|
@touch $$@
|
||||||
|
|
||||||
|
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
|
||||||
|
export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3)))
|
||||||
|
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
|
||||||
|
export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3)))
|
||||||
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
|
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
|
||||||
$(S)src/test/run-make/%/Makefile \
|
$(S)src/test/run-make/%/Makefile \
|
||||||
$$(CSREQ$(1)_T_$(2)_H_$(3))
|
$$(CSREQ$(1)_T_$(2)_H_$(3))
|
||||||
|
@ -1056,7 +1060,7 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
|
||||||
$$(MAKE) \
|
$$(MAKE) \
|
||||||
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
|
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
|
||||||
$(3)/test/run-make/$$* \
|
$(3)/test/run-make/$$* \
|
||||||
$$(CC_$(3)) \
|
'$$(CC_$(3))' \
|
||||||
"$$(CFG_GCCISH_CFLAGS_$(3))" \
|
"$$(CFG_GCCISH_CFLAGS_$(3))" \
|
||||||
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
|
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
|
||||||
"$$(TESTNAME)" \
|
"$$(TESTNAME)" \
|
||||||
|
@ -1064,7 +1068,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
|
||||||
"$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))" \
|
"$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))" \
|
||||||
"$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))" \
|
"$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))" \
|
||||||
$(1) \
|
$(1) \
|
||||||
$$(S)
|
$$(S) \
|
||||||
|
$(3)
|
||||||
@touch -r $$@.start_time $$@ && rm $$@.start_time
|
@touch -r $$@.start_time $$@ && rm $$@.start_time
|
||||||
else
|
else
|
||||||
# FIXME #11094 - The above rule doesn't work right for multiple targets
|
# FIXME #11094 - The above rule doesn't work right for multiple targets
|
||||||
|
|
|
@ -12,6 +12,7 @@ import subprocess
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
target_triple = sys.argv[14]
|
||||||
|
|
||||||
def normalize_path(v):
|
def normalize_path(v):
|
||||||
"""msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
|
"""msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
|
||||||
|
@ -22,8 +23,11 @@ def normalize_path(v):
|
||||||
windows paths so it is really error-prone. revert it for peace."""
|
windows paths so it is really error-prone. revert it for peace."""
|
||||||
v = v.replace('\\', '/')
|
v = v.replace('\\', '/')
|
||||||
# c:/path -> /c/path
|
# c:/path -> /c/path
|
||||||
if ':/' in v:
|
# "c:/path" -> "/c/path"
|
||||||
v = '/' + v.replace(':/', '/')
|
start = v.find(':/')
|
||||||
|
while start != -1:
|
||||||
|
v = v[:start - 1] + '/' + v[start - 1:start] + v[start + 1:]
|
||||||
|
start = v.find(':/')
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +54,10 @@ putenv('TARGET_RPATH_DIR', os.path.abspath(sys.argv[11]))
|
||||||
putenv('RUST_BUILD_STAGE', sys.argv[12])
|
putenv('RUST_BUILD_STAGE', sys.argv[12])
|
||||||
putenv('S', os.path.abspath(sys.argv[13]))
|
putenv('S', os.path.abspath(sys.argv[13]))
|
||||||
putenv('PYTHON', sys.executable)
|
putenv('PYTHON', sys.executable)
|
||||||
|
os.putenv('TARGET', target_triple)
|
||||||
|
|
||||||
|
if 'msvc' in target_triple:
|
||||||
|
os.putenv('IS_MSVC', '1')
|
||||||
|
|
||||||
if filt not in sys.argv[1]:
|
if filt not in sys.argv[1]:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
all:
|
all:
|
||||||
mkdir $(TMPDIR)/a
|
mkdir $(TMPDIR)/a
|
||||||
mkdir $(TMPDIR)/b
|
mkdir $(TMPDIR)/b
|
||||||
$(CC) -c -o $(TMPDIR)/a/foo.o foo.c
|
$(call COMPILE_OBJ,$(TMPDIR)/a/foo.o,foo.c)
|
||||||
$(CC) -c -o $(TMPDIR)/b/foo.o bar.c
|
$(call COMPILE_OBJ,$(TMPDIR)/b/foo.o,bar.c)
|
||||||
ar crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o
|
ar crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o
|
||||||
$(RUSTC) foo.rs
|
$(RUSTC) foo.rs
|
||||||
$(RUSTC) bar.rs
|
$(RUSTC) bar.rs
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
// ignore-license
|
// ignore-license
|
||||||
|
#ifdef _WIN32
|
||||||
|
__declspec(dllexport)
|
||||||
|
#endif
|
||||||
int foo() { return 0; }
|
int foo() { return 0; }
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
// ignore-license
|
// ignore-license
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
__declspec(dllexport)
|
||||||
|
#endif
|
||||||
int foo() { return 0; }
|
int foo() { return 0; }
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
HOST_LIB_DIR=$(TMPDIR)/../../../stage$(RUST_BUILD_STAGE)/lib
|
all: $(TMPDIR)/$(call BIN,bar)
|
||||||
|
|
||||||
all:
|
|
||||||
$(RUSTC) foo.rs
|
|
||||||
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(call RPATH_LINK_SEARCH,$(HOST_LIB_DIR)) -Wl,-rpath,$(TMPDIR) $(EXTRACFLAGS)
|
|
||||||
$(call RUN,bar)
|
$(call RUN,bar)
|
||||||
$(call REMOVE_DYLIBS,foo)
|
$(call REMOVE_DYLIBS,foo)
|
||||||
$(call FAIL,bar)
|
$(call FAIL,bar)
|
||||||
|
|
||||||
|
ifdef IS_MSVC
|
||||||
|
$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo)
|
||||||
|
$(CC) bar.c $(TMPDIR)/foo.lib $(call OUT_EXE,bar)
|
||||||
|
else
|
||||||
|
$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo)
|
||||||
|
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -L $(TMPDIR)
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(call DYLIB,foo): foo.rs
|
||||||
|
$(RUSTC) foo.rs
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
EXTRAFLAGS := $(EXTRACFLAGS)
|
|
||||||
|
|
||||||
# FIXME: ignore freebsd
|
# FIXME: ignore freebsd
|
||||||
ifneq ($(shell uname),FreeBSD)
|
ifneq ($(shell uname),FreeBSD)
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs
|
$(RUSTC) foo.rs
|
||||||
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(EXTRAFLAGS) $(EXTRACXXFLAGS)
|
cp $(TMPDIR)/libfoo.a $(call NATIVE_STATICLIB,foo2)
|
||||||
|
$(CC) bar.c $(call NATIVE_STATICLIB,foo2) $(call OUT_EXE,bar) \
|
||||||
|
$(EXTRACFLAGS) $(EXTRACXXFLAGS)
|
||||||
$(call RUN,bar)
|
$(call RUN,bar)
|
||||||
rm $(call STATICLIB,foo*)
|
rm $(call STATICLIB,foo*)
|
||||||
$(call RUN,bar)
|
$(call RUN,bar)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all: $(call STATICLIB,cfoo)
|
all: $(call NATIVE_STATICLIB,cfoo)
|
||||||
$(RUSTC) foo.rs -C prefer-dynamic
|
$(RUSTC) foo.rs -C prefer-dynamic
|
||||||
$(RUSTC) bar.rs
|
$(RUSTC) bar.rs
|
||||||
rm $(TMPDIR)/$(call STATICLIB_GLOB,cfoo)
|
rm $(call NATIVE_STATICLIB,cfoo)
|
||||||
$(call RUN,bar)
|
$(call RUN,bar)
|
||||||
$(call REMOVE_DYLIBS,foo)
|
$(call REMOVE_DYLIBS,foo)
|
||||||
$(call FAIL,bar)
|
$(call FAIL,bar)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all: $(call STATICLIB,cfoo)
|
all: $(call NATIVE_STATICLIB,cfoo)
|
||||||
$(RUSTC) foo.rs
|
$(RUSTC) foo.rs
|
||||||
$(RUSTC) bar.rs
|
$(RUSTC) bar.rs
|
||||||
$(call REMOVE_RLIBS,foo)
|
$(call REMOVE_RLIBS,foo)
|
||||||
rm $(TMPDIR)/$(call STATICLIB_GLOB,cfoo)
|
rm $(call NATIVE_STATICLIB,cfoo)
|
||||||
$(call RUN,bar)
|
$(call RUN,bar)
|
||||||
|
|
|
@ -7,5 +7,5 @@ all:
|
||||||
rm $(TMPDIR)/$(call BIN,bar)
|
rm $(TMPDIR)/$(call BIN,bar)
|
||||||
$(RUSTC) foo1.rs
|
$(RUSTC) foo1.rs
|
||||||
rm $(TMPDIR)/$(call BIN,foo)
|
rm $(TMPDIR)/$(call BIN,foo)
|
||||||
$(RUSTC) foo1.rs -o $(TMPDIR)/bar1
|
$(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1)
|
||||||
rm $(TMPDIR)/$(call BIN,bar1)
|
rm $(TMPDIR)/$(call BIN,bar1)
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
all: $(call NATIVE_STATICLIB,test)
|
||||||
$(CC) -std=c99 test.c -c -o $(TMPDIR)/test.o
|
$(RUSTC) testcrate.rs
|
||||||
$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
|
$(RUSTC) test.rs
|
||||||
$(RUSTC) testcrate.rs -L $(TMPDIR)
|
|
||||||
$(RUSTC) test.rs -L $(TMPDIR)
|
|
||||||
$(call RUN,test) || exit 1
|
$(call RUN,test) || exit 1
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
all: $(call NATIVE_STATICLIB,test)
|
||||||
$(CC) -std=c99 test.c -c -o $(TMPDIR)/test.o
|
$(RUSTC) test.rs
|
||||||
$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
|
|
||||||
$(RUSTC) test.rs -L $(TMPDIR)
|
|
||||||
$(call RUN,test) || exit 1
|
$(call RUN,test) || exit 1
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
all: $(call NATIVE_STATICLIB,test)
|
||||||
$(CC) -std=c99 test.c -c -o $(TMPDIR)/test.o
|
$(RUSTC) test.rs
|
||||||
$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
|
|
||||||
$(RUSTC) test.rs -L $(TMPDIR)
|
|
||||||
$(call RUN,test) || exit 1
|
$(call RUN,test) || exit 1
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
// ignore-license
|
// ignore-license
|
||||||
// Pragma needed cause of gcc bug on windows: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
|
// Pragma needed cause of gcc bug on windows: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(push,1)
|
||||||
|
struct Foo {
|
||||||
|
char a;
|
||||||
|
short b;
|
||||||
|
char c;
|
||||||
|
};
|
||||||
|
#else
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
struct __attribute__((packed)) Foo {
|
struct __attribute__((packed)) Foo {
|
||||||
char a;
|
char a;
|
||||||
short b;
|
short b;
|
||||||
char c;
|
char c;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Foo foo(struct Foo foo) {
|
struct Foo foo(struct Foo foo) {
|
||||||
return foo;
|
return foo;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
all: $(call NATIVE_STATICLIB,test)
|
||||||
$(CC) -std=c99 test.c -c -o $(TMPDIR)/test.o
|
$(RUSTC) testcrate.rs
|
||||||
$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
|
$(RUSTC) test.rs
|
||||||
$(RUSTC) testcrate.rs -L $(TMPDIR)
|
|
||||||
$(RUSTC) test.rs -L $(TMPDIR)
|
|
||||||
$(call RUN,test) || exit 1
|
$(call RUN,test) || exit 1
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo'
|
# correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo'
|
||||||
# library will be stripped out, and the linkage will fail.
|
# library will be stripped out, and the linkage will fail.
|
||||||
|
|
||||||
all: $(call STATICLIB,foo) $(call STATICLIB,bar)
|
all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar)
|
||||||
$(RUSTC) foo.rs
|
$(RUSTC) foo.rs
|
||||||
$(RUSTC) bar.rs
|
$(RUSTC) bar.rs
|
||||||
$(RUSTC) main.rs -Z print-link-args
|
$(RUSTC) main.rs -Z print-link-args
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all: $(call STATICLIB,foo)
|
all: $(call NATIVE_STATICLIB,foo)
|
||||||
$(RUSTC) foo.rs
|
$(RUSTC) foo.rs
|
||||||
$(RUSTC) bar.rs
|
$(RUSTC) bar.rs
|
||||||
$(call RUN,bar)
|
$(call RUN,bar)
|
||||||
|
|
|
@ -13,5 +13,5 @@ endif
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs --crate-type=rlib
|
$(RUSTC) foo.rs --crate-type=rlib
|
||||||
$(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a
|
$(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a
|
||||||
$(CC) foo.c -lbar -o $(call RUN_BINFILE,foo) $(EXTRACFLAGS)
|
$(CC) foo.c $(TMPDIR)/libbar.a $(EXTRACFLAGS) $(call OUT_EXE,foo)
|
||||||
$(call RUN,foo)
|
$(call RUN,foo)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all: $(TMPDIR)/libfoo.a
|
all: $(call NATIVE_STATICLIB,foo)
|
||||||
$(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic
|
$(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic
|
||||||
$(RUSTC) bar.rs
|
$(RUSTC) bar.rs
|
||||||
$(call RUN,bar)
|
$(call RUN,bar)
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
// ignore-license
|
// ignore-license
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
__declspec(dllexport)
|
||||||
|
#endif
|
||||||
void foo() {}
|
void foo() {}
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(linked_from)]
|
||||||
#![crate_type = "dylib"]
|
#![crate_type = "dylib"]
|
||||||
|
|
||||||
#[link(name = "foo", kind = "static")]
|
#[link(name = "foo", kind = "static")]
|
||||||
|
#[linked_from = "foo"]
|
||||||
extern {
|
extern {
|
||||||
pub fn foo();
|
pub fn foo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
all: $(call NATIVE_STATICLIB,test)
|
||||||
$(CC) -std=c99 test.c -c -o $(TMPDIR)/test.o
|
$(RUSTC) test.rs
|
||||||
$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
|
|
||||||
$(RUSTC) test.rs -L $(TMPDIR)
|
|
||||||
$(call RUN,test) || exit 1
|
$(call RUN,test) || exit 1
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) -o "" blank.rs 2>&1 | \
|
$(RUSTC) -o "" blank.rs 2>&1 | \
|
||||||
grep 'No such file or directory'
|
grep -i 'No such file or directory'
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
CORRECT_DIR=$(TMPDIR)/correct
|
CORRECT_DIR=$(TMPDIR)/correct
|
||||||
WRONG_DIR=$(TMPDIR)/wrong
|
WRONG_DIR=$(TMPDIR)/wrong
|
||||||
|
|
||||||
all: $(TMPDIR)/libcorrect.a $(TMPDIR)/libwrong.a
|
F := $(call NATIVE_STATICLIB_FILE,foo)
|
||||||
|
|
||||||
|
all: $(call NATIVE_STATICLIB,correct) $(call NATIVE_STATICLIB,wrong)
|
||||||
mkdir -p $(CORRECT_DIR) $(WRONG_DIR)
|
mkdir -p $(CORRECT_DIR) $(WRONG_DIR)
|
||||||
mv $(TMPDIR)/libcorrect.a $(CORRECT_DIR)/libfoo.a
|
mv $(call NATIVE_STATICLIB,correct) $(CORRECT_DIR)/$(F)
|
||||||
mv $(TMPDIR)/libwrong.a $(WRONG_DIR)/libfoo.a
|
mv $(call NATIVE_STATICLIB,wrong) $(WRONG_DIR)/$(F)
|
||||||
$(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR)
|
$(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR)
|
||||||
$(call RUN,should_succeed)
|
$(call RUN,should_succeed)
|
||||||
$(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR)
|
$(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
all: $(call NATIVE_STATICLIB,foo)
|
||||||
$(CC) foo.c -c -o $(TMPDIR)/foo.o
|
$(RUSTC) bar.rs
|
||||||
$(AR) rcs $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o
|
|
||||||
$(RUSTC) bar.rs -lfoo -L $(TMPDIR)
|
|
||||||
$(call RUN,bar) || exit 1
|
$(call RUN,bar) || exit 1
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#[linkage = "external"]
|
#[linkage = "external"]
|
||||||
static BAZ: i32 = 21;
|
static BAZ: i32 = 21;
|
||||||
|
|
||||||
|
#[link(name = "foo", kind = "static")]
|
||||||
extern {
|
extern {
|
||||||
fn what() -> i32;
|
fn what() -> i32;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,7 @@ CC := $(CC:-g=)
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs -C lto
|
$(RUSTC) foo.rs -C lto
|
||||||
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(EXTRACFLAGS) $(EXTRACXXFLAGS)
|
$(CC) bar.c $(TMPDIR)/libfoo.a \
|
||||||
|
$(call OUT_EXE,bar) \
|
||||||
|
$(EXTRACFLAGS) $(EXTRACXXFLAGS)
|
||||||
$(call RUN,bar)
|
$(call RUN,bar)
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
|
ifdef IS_MSVC
|
||||||
|
# FIXME(#27979)
|
||||||
|
all:
|
||||||
|
else
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs
|
$(RUSTC) foo.rs
|
||||||
$(RUSTC) bar.rs
|
$(RUSTC) bar.rs
|
||||||
$(RUSTC) main.rs
|
$(RUSTC) main.rs
|
||||||
$(call RUN,main)
|
$(call RUN,main)
|
||||||
|
endif
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
// ignore-license
|
|
||||||
extern void foo();
|
|
||||||
|
|
||||||
void bar() { foo(); }
|
|
|
@ -1,2 +0,0 @@
|
||||||
// ignore-license
|
|
||||||
void foo() {}
|
|
|
@ -4,7 +4,8 @@ all:
|
||||||
$(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib
|
$(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib
|
||||||
$(call REMOVE_RLIBS,bar)
|
$(call REMOVE_RLIBS,bar)
|
||||||
$(call REMOVE_DYLIBS,bar)
|
$(call REMOVE_DYLIBS,bar)
|
||||||
rm $(TMPDIR)/$(call STATICLIB_GLOB,bar)
|
rm $(TMPDIR)/libbar.a
|
||||||
|
rm -f $(TMPDIR)/bar.{exp,lib}
|
||||||
# Check that $(TMPDIR) is empty.
|
# Check that $(TMPDIR) is empty.
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ all:
|
||||||
rm $(TMPDIR)/foo
|
rm $(TMPDIR)/foo
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
$(RUSTC) foo.rs --emit=link -o $(TMPDIR)/foo
|
$(RUSTC) foo.rs --emit=link -o $(TMPDIR)/$(call BIN,foo)
|
||||||
rm $(TMPDIR)/$(call BIN,foo)
|
rm $(TMPDIR)/$(call BIN,foo)
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
|
@ -44,15 +45,16 @@ all:
|
||||||
rm $(TMPDIR)/foo
|
rm $(TMPDIR)/foo
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
$(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/foo
|
$(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/$(call BIN,foo)
|
||||||
rm $(TMPDIR)/$(call BIN,foo) # FIXME 13794
|
rm $(TMPDIR)/$(call BIN,foo)
|
||||||
|
rm -f $(TMPDIR)/foo.{exp,lib}
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
$(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo
|
$(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo
|
||||||
rm $(TMPDIR)/foo
|
rm $(TMPDIR)/foo
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
$(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/foo
|
$(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/$(call BIN,foo)
|
||||||
rm $(TMPDIR)/$(call BIN,foo)
|
rm $(TMPDIR)/$(call BIN,foo)
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ all:
|
||||||
rm $(TMPDIR)/bar.ll
|
rm $(TMPDIR)/bar.ll
|
||||||
rm $(TMPDIR)/bar.s
|
rm $(TMPDIR)/bar.s
|
||||||
rm $(TMPDIR)/bar.o
|
rm $(TMPDIR)/bar.o
|
||||||
rm $(TMPDIR)/$(call STATICLIB_GLOB,bar)
|
rm $(TMPDIR)/libbar.a
|
||||||
mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc
|
mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc
|
||||||
# Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later
|
# Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later
|
||||||
# comparison.
|
# comparison.
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
all: others
|
||||||
$(RUSTC) -C relocation-model=dynamic-no-pic foo.rs
|
$(RUSTC) -C relocation-model=dynamic-no-pic foo.rs
|
||||||
$(call RUN,foo)
|
$(call RUN,foo)
|
||||||
|
|
||||||
$(RUSTC) -C relocation-model=default foo.rs
|
$(RUSTC) -C relocation-model=default foo.rs
|
||||||
$(call RUN,foo)
|
$(call RUN,foo)
|
||||||
|
|
||||||
|
$(RUSTC) -C relocation-model=default --crate-type=dylib foo.rs
|
||||||
|
$(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs
|
||||||
|
|
||||||
|
ifdef IS_MSVC
|
||||||
|
# FIXME(#28026)
|
||||||
|
others:
|
||||||
|
else
|
||||||
|
others:
|
||||||
$(RUSTC) -C relocation-model=static foo.rs
|
$(RUSTC) -C relocation-model=static foo.rs
|
||||||
$(call RUN,foo)
|
$(call RUN,foo)
|
||||||
|
|
||||||
$(RUSTC) -C relocation-model=default --crate-type=dylib foo.rs
|
|
||||||
$(RUSTC) -C relocation-model=static --crate-type=dylib foo.rs
|
$(RUSTC) -C relocation-model=static --crate-type=dylib foo.rs
|
||||||
$(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs
|
endif
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
|
TO_LINK := $(call DYLIB,bar)
|
||||||
|
ifdef IS_MSVC
|
||||||
|
LINK_ARG = $(TO_LINK:dll=lib)
|
||||||
|
else
|
||||||
|
LINK_ARG = $(TO_LINK)
|
||||||
|
endif
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs
|
$(RUSTC) foo.rs
|
||||||
$(RUSTC) bar.rs
|
$(RUSTC) bar.rs
|
||||||
$(CC) main.c -o $(call RUN_BINFILE,main) -lbar $(EXTRACFLAGS)
|
$(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS)
|
||||||
rm $(TMPDIR)/*.rlib
|
rm $(TMPDIR)/*.rlib
|
||||||
rm $(call DYLIB,foo)
|
rm $(call DYLIB,foo)
|
||||||
$(call RUN,main)
|
$(call RUN,main)
|
||||||
|
|
|
@ -7,7 +7,7 @@ TARGET_RPATH_ENV = \
|
||||||
|
|
||||||
BARE_RUSTC := $(HOST_RPATH_ENV) $(RUSTC)
|
BARE_RUSTC := $(HOST_RPATH_ENV) $(RUSTC)
|
||||||
RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
|
RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
|
||||||
CC := $(CC) -L $(TMPDIR)
|
#CC := $(CC) -L $(TMPDIR)
|
||||||
HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py
|
HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py
|
||||||
|
|
||||||
# This is the name of the binary we will generate and run; use this
|
# This is the name of the binary we will generate and run; use this
|
||||||
|
@ -19,8 +19,6 @@ RUN_BINFILE = $(TMPDIR)/$(1)
|
||||||
# variable before running the binary.
|
# variable before running the binary.
|
||||||
|
|
||||||
RLIB_GLOB = lib$(1)*.rlib
|
RLIB_GLOB = lib$(1)*.rlib
|
||||||
STATICLIB = $(TMPDIR)/lib$(1).a
|
|
||||||
STATICLIB_GLOB = lib$(1)*.a
|
|
||||||
BIN = $(1)
|
BIN = $(1)
|
||||||
|
|
||||||
UNAME = $(shell uname)
|
UNAME = $(shell uname)
|
||||||
|
@ -33,27 +31,48 @@ RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
|
||||||
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
|
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
|
||||||
DYLIB_GLOB = lib$(1)*.dylib
|
DYLIB_GLOB = lib$(1)*.dylib
|
||||||
DYLIB = $(TMPDIR)/lib$(1).dylib
|
DYLIB = $(TMPDIR)/lib$(1).dylib
|
||||||
RPATH_LINK_SEARCH =
|
STATICLIB = $(TMPDIR)/lib$(1).a
|
||||||
|
STATICLIB_GLOB = lib$(1)*.a
|
||||||
else
|
else
|
||||||
ifdef IS_WINDOWS
|
ifdef IS_WINDOWS
|
||||||
RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
|
RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
|
||||||
FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
|
FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
|
||||||
DYLIB_GLOB = $(1)*.dll
|
DYLIB_GLOB = $(1)*.dll
|
||||||
DYLIB = $(TMPDIR)/$(1).dll
|
DYLIB = $(TMPDIR)/$(1).dll
|
||||||
|
STATICLIB = $(TMPDIR)/$(1).lib
|
||||||
|
STATICLIB_GLOB = $(1)*.lib
|
||||||
BIN = $(1).exe
|
BIN = $(1).exe
|
||||||
RPATH_LINK_SEARCH =
|
|
||||||
else
|
else
|
||||||
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
|
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
|
||||||
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
|
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
|
||||||
DYLIB_GLOB = lib$(1)*.so
|
DYLIB_GLOB = lib$(1)*.so
|
||||||
DYLIB = $(TMPDIR)/lib$(1).so
|
DYLIB = $(TMPDIR)/lib$(1).so
|
||||||
RPATH_LINK_SEARCH = -Wl,-rpath-link=$(1)
|
STATICLIB = $(TMPDIR)/lib$(1).a
|
||||||
|
STATICLIB_GLOB = lib$(1)*.a
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef IS_MSVC
|
||||||
|
COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2)
|
||||||
|
NATIVE_STATICLIB_FILE = $(1).lib
|
||||||
|
NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1))
|
||||||
|
OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \
|
||||||
|
-Fo:`cygpath -w $(TMPDIR)/$(1).obj`
|
||||||
|
else
|
||||||
|
COMPILE_OBJ = $(CC) -c -o $(1) $(2)
|
||||||
|
NATIVE_STATICLIB_FILE = lib$(1).a
|
||||||
|
NATIVE_STATICLIB = $(call STATICLIB,$(1))
|
||||||
|
OUT_EXE=-o $(TMPDIR)/$(1)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
# Extra flags needed to compile a working executable with the standard library
|
# Extra flags needed to compile a working executable with the standard library
|
||||||
ifdef IS_WINDOWS
|
ifdef IS_WINDOWS
|
||||||
|
ifdef IS_MSVC
|
||||||
|
EXTRACFLAGS := ws2_32.lib userenv.lib shell32.lib advapi32.lib
|
||||||
|
else
|
||||||
EXTRACFLAGS := -lws2_32 -luserenv
|
EXTRACFLAGS := -lws2_32 -luserenv
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
ifeq ($(UNAME),Darwin)
|
ifeq ($(UNAME),Darwin)
|
||||||
else
|
else
|
||||||
|
@ -80,12 +99,20 @@ REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
|
||||||
|
|
||||||
%.a: %.o
|
%.a: %.o
|
||||||
ar crus $@ $<
|
ar crus $@ $<
|
||||||
|
%.lib: lib%.o
|
||||||
|
ar crus $@ $<
|
||||||
%.dylib: %.o
|
%.dylib: %.o
|
||||||
$(CC) -dynamiclib -Wl,-dylib -o $@ $<
|
$(CC) -dynamiclib -Wl,-dylib -o $@ $<
|
||||||
%.so: %.o
|
%.so: %.o
|
||||||
$(CC) -o $@ $< -shared
|
$(CC) -o $@ $< -shared
|
||||||
|
|
||||||
|
ifdef IS_MSVC
|
||||||
|
%.dll: lib%.o
|
||||||
|
$(CC) $< -link -dll -out:`cygpath -w $@`
|
||||||
|
else
|
||||||
%.dll: lib%.o
|
%.dll: lib%.o
|
||||||
$(CC) -o $@ $< -shared
|
$(CC) -o $@ $< -shared
|
||||||
|
endif
|
||||||
|
|
||||||
$(TMPDIR)/lib%.o: %.c
|
$(TMPDIR)/lib%.o: %.c
|
||||||
$(CC) -c -o $@ $<
|
$(call COMPILE_OBJ,$@,$<)
|
||||||
|
|
Loading…
Reference in New Issue