Skip to content

Commit 20946e6

Browse files
nikomatsakisbrson
authored andcommitted
start going back to an i386 build
1 parent 8011e3f commit 20946e6

File tree

12 files changed

+69
-61
lines changed

12 files changed

+69
-61
lines changed

Makefile.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ include config.mk
5050
OUR_MKFILES := Makefile config.mk $(wildcard $(CFG_SRC_DIR)/mk/*.mk)
5151
3RDPARTY_MKFILES := $(CFG_SRC_DIR)/src/rt/libuv/Makefile \
5252
$(wildcard $(CFG_SRC_DIR)/src/rt/libuv/*.mk)
53-
GEN_MKFILES := $(wildcard $(CFG_SRC_DIR)/mk/libuv/mac/*) \
54-
$(wildcard $(CFG_SRC_DIR)/mk/libuv/unix/*) \
55-
$(wildcard $(CFG_SRC_DIR)/mk/libuv/win/*) \
53+
GEN_MKFILES := $(wildcard $(CFG_SRC_DIR)/mk/libuv/*/*/*) \
5654
$(wildcard $(CFG_SRC_DIR)/mk/libuv/mac/src/rt/libuv/*) \
5755
$(wildcard $(CFG_SRC_DIR)/mk/libuv/mac/src/rt/libuv/*) \
5856
$(wildcard $(CFG_SRC_DIR)/mk/libuv/mac/src/rt/libuv/*)

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ step_msg "making directories"
391391
for i in \
392392
doc doc/std \
393393
nd nd/std \
394-
rt rt/isaac rt/bigint rt/sync rt/test rt/arch/i386 \
394+
rt rt/isaac rt/bigint rt/sync rt/test rt/arch/i386 rt/arch/x86_64 \
395395
rt/libuv rt/libuv/src/ares rt/libuv/src/eio rt/libuv/src/ev \
396396
rustllvm dl \
397397
test/run-pass test/run-fail test/compile-fail \

mk/libuv/x86_64/mac/src/rt/libuv/run-benchmarks.target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CFLAGS_Default := -fasm-blocks \
99
-mpascal-strings \
1010
-Os \
1111
-gdwarf-2 \
12-
-arch i386
12+
-arch x86_64
1313

1414
# Flags passed to only C files.
1515
CFLAGS_C_Default :=
@@ -68,7 +68,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD
6868

6969
# End of this set of suffix rules
7070
### Rules for final target.
71-
LDFLAGS_Default := -arch i386 \
71+
LDFLAGS_Default := -arch x86_64 \
7272
-L$(builddir)
7373

7474
LIBS := -framework Carbon \

mk/libuv/x86_64/mac/src/rt/libuv/run-tests.target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CFLAGS_Default := -fasm-blocks \
1212
-mpascal-strings \
1313
-Os \
1414
-gdwarf-2 \
15-
-arch i386
15+
-arch x86_64
1616

1717
# Flags passed to only C files.
1818
CFLAGS_C_Default :=
@@ -104,7 +104,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD
104104

105105
# End of this set of suffix rules
106106
### Rules for final target.
107-
LDFLAGS_Default := -arch i386 \
107+
LDFLAGS_Default := -arch x86_64 \
108108
-L$(builddir)
109109

110110
LIBS := -framework Carbon \

mk/libuv/x86_64/mac/src/rt/libuv/uv.target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CFLAGS_Default := -fasm-blocks \
1515
-mpascal-strings \
1616
-Os \
1717
-gdwarf-2 \
18-
-arch i386
18+
-arch x86_64
1919

2020
# Flags passed to only C files.
2121
CFLAGS_C_Default :=
@@ -120,7 +120,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD
120120

121121
# End of this set of suffix rules
122122
### Rules for final target.
123-
LDFLAGS_Default := -arch i386 \
123+
LDFLAGS_Default := -arch x86_64 \
124124
-L$(builddir)
125125

126126
LIBS := -lm

mk/platform.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
6666
# approaches welcome!
6767
#
6868
# NB: Currently GCC's optimizer breaks rustrt (task-comm-1 hangs) on Darwin.
69-
CFG_GCC_CFLAGS += -m64 #NDM
70-
CFG_CLANG_CFLAGS += -m64 #NDM
69+
CFG_GCC_CFLAGS += -m32
70+
CFG_CLANG_CFLAGS += -m32
7171
ifeq ($(CFG_CPUTYPE), x86_64)
72-
CFG_GCCISH_CFLAGS += -arch x86_64 #NDM
73-
CFG_GCCISH_LINK_FLAGS += -arch x86_64 #NDM
72+
CFG_GCCISH_CFLAGS += -arch i386
73+
CFG_GCCISH_LINK_FLAGS += -arch i386
7474
endif
75-
CFG_GCCISH_LINK_FLAGS += -m64
75+
CFG_GCCISH_LINK_FLAGS += -m32
7676
CFG_DSYMUTIL := dsymutil
7777
CFG_DEF_SUFFIX := .darwin.def
7878
# Mac requires this flag to make rpath work

mk/rt.mk

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ RUNTIME_CS := rt/sync/timer.cpp \
3232
rt/memory_region.cpp \
3333
rt/test/rust_test_harness.cpp \
3434
rt/test/rust_test_runtime.cpp \
35-
rt/test/rust_test_util.cpp #NDM
36-
#NDM rt/arch/i386/context.cpp
35+
rt/test/rust_test_util.cpp \
36+
rt/arch/i386/context.cpp
3737

3838
RUNTIME_LL :=
3939

@@ -76,25 +76,30 @@ RUNTIME_HDR := rt/globals.h \
7676
rt/test/rust_test_harness.h \
7777
rt/test/rust_test_runtime.h \
7878
rt/test/rust_test_util.h \
79+
<<<<<<< HEAD
7980
rt/arch/i386/context.h
81+
=======
82+
rt/arch/i386/context.h
83+
>>>>>>> start going back to an i386 build
8084

8185
ifeq ($(CFG_WINDOWSY), 1)
8286
LIBUV_OSTYPE := win
83-
LIBUV_ARCH := x86_64 #NDM
87+
LIBUV_ARCH := i386
8488
LIBUV_LIB := rt/libuv/Default/obj.target/src/rt/libuv/libuv.a
8589
else ifeq ($(CFG_OSTYPE), apple-darwin)
8690
LIBUV_OSTYPE := mac
87-
LIBUV_ARCH := x86_64 #NDM
91+
LIBUV_ARCH := i386
8892
LIBUV_LIB := rt/libuv/Default/libuv.a
8993
else
9094
LIBUV_OSTYPE := unix
91-
LIBUV_ARCH := x86_64 #NDM
95+
LIBUV_ARCH := i386
9296
LIBUV_LIB := rt/libuv/Default/obj.target/src/rt/libuv/libuv.a
9397
endif
9498

9599
RUNTIME_DEF := rt/rustrt$(CFG_DEF_SUFFIX)
96100
RUNTIME_INCS := -I $(S)src/rt/isaac -I $(S)src/rt/uthash \
97-
-I $(S)src/rt/arch/i386 -I $(S)src/rt/libuv/include
101+
-I $(S)src/rt/arch/x86_64 \
102+
-I $(S)src/rt/libuv/include
98103
RUNTIME_OBJS := $(RUNTIME_CS:.cpp=.o) $(RUNTIME_LL:.ll=.o) $(RUNTIME_S:.S=.o)
99104
RUNTIME_LIBS := $(LIBUV_LIB)
100105

src/etc/gyp-uv

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ do
4040

4141
# Comment out the gyp auto regeneration
4242
for os in mac unix win; do
43-
sed -i ".save" \
43+
sed -i "" \
4444
-e 's/^\(Makefile: $(srcdir)\/src\/rt\/libuv\/uv\.gyp\)/#\1/' \
4545
mk/libuv/$ARCH/$os/Makefile
4646

47-
sed -i ".save" \
47+
sed -i "" \
4848
-e 's/^\( $(call do_cmd,regen_makefile)\)/#\1/' \
4949
mk/libuv/$ARCH/$os/Makefile
50-
51-
rm mk/libuv/$ARCH/$os/Makefile.save
5250
done
5351
done
52+
53+
# On Mac, GYP hardcodes a -arch i386 into the output. Fix that.
54+
sed -i "" \
55+
-e 's/-arch i386/-arch x86_64/' \
56+
mk/libuv/x86_64/mac/src/rt/libuv/*.mk

src/rt/arch/x86_64/_context.S

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,44 +54,44 @@ swap_registers:
5454
// jump back into the old code.
5555

5656
// Save instruction pointer:
57-
popl %rax
58-
movl %rax, 104(%rdi)
57+
pop %rax
58+
mov %rax, 104(%rdi)
5959

6060
// Save non-volatile integer registers:
6161
// (including RSP)
62-
movl %rbx, 0(%rdi)
63-
movl %rsp, 8(%rdi)
64-
movl %rbp, 16(%rdi)
65-
movl %r12, 24(%rdi)
66-
movl %r13, 32(%rdi)
67-
movl %r14, 40(%rdi)
68-
movl %r15, 48(%rdi)
62+
mov %rbx, 0(%rdi)
63+
mov %rsp, 8(%rdi)
64+
mov %rbp, 16(%rdi)
65+
mov %r12, 24(%rdi)
66+
mov %r13, 32(%rdi)
67+
mov %r14, 40(%rdi)
68+
mov %r15, 48(%rdi)
6969

7070
// Save non-volatile XMM registers:
71-
movl %xmm0, 56(%rdi)
72-
movl %xmm1, 64(%rdi)
73-
movl %xmm2, 72(%rdi)
74-
movl %xmm3, 80(%rdi)
75-
movl %xmm4, 88(%rdi)
76-
movl %xmm5, 96(%rdi)
71+
movapd %xmm0, 56(%rdi)
72+
movapd %xmm1, 64(%rdi)
73+
movapd %xmm2, 72(%rdi)
74+
movapd %xmm3, 80(%rdi)
75+
movapd %xmm4, 88(%rdi)
76+
movapd %xmm5, 96(%rdi)
7777

7878
// Restore non-volatile integer registers:
7979
// (including RSP)
80-
movl 0(%rsi), %rbx
81-
movl 8(%rsi), %rsp
82-
movl 16(%rsi), %rbp
83-
movl 24(%rsi), %r12
84-
movl 32(%rsi), %r13
85-
movl 40(%rsi), %r14
86-
movl 48(%rsi), %r15
80+
mov 0(%rsi), %rbx
81+
mov 8(%rsi), %rsp
82+
mov 16(%rsi), %rbp
83+
mov 24(%rsi), %r12
84+
mov 32(%rsi), %r13
85+
mov 40(%rsi), %r14
86+
mov 48(%rsi), %r15
8787

8888
// Restore non-volatile XMM registers:
89-
movl 56(%rsi), %xmm0
90-
movl 64(%rsi), %xmm1
91-
movl 72(%rsi), %xmm2
92-
movl 80(%rsi), %xmm3
93-
movl 88(%rsi), %xmm4
94-
movl 96(%rsi), %xmm5
89+
movapd 56(%rsi), %xmm0
90+
movapd 64(%rsi), %xmm1
91+
movapd 72(%rsi), %xmm2
92+
movapd 80(%rsi), %xmm3
93+
movapd 88(%rsi), %xmm4
94+
movapd 96(%rsi), %xmm5
9595

9696
// Jump to the instruction pointer
9797
// found in regs:

src/rt/arch/x86_64/ccall.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ _upcall_call_c_stack:
1111
.globl upcall_call_c_stack
1212
upcall_call_c_stack:
1313
#endif
14-
pushl %rbp
15-
movl %rsp,%rbp // save rsp
16-
movl %rsi,%rsp // switch stack
17-
calll *%rdi
18-
movl %rbp,%rsp // would like to use "leave" but it's slower
19-
popl %rbp
14+
push %rbp
15+
mov %rsp,%rbp // save rsp
16+
mov %rsi,%rsp // switch stack
17+
call *%rdi
18+
mov %rbp,%rsp // would like to use "leave" but it's slower
19+
pop %rbp
2020
ret
2121

src/rt/arch/x86_64/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ void context::call(void *f, void *arg, void *stack) {
3333
*--sp = (uint64_t)arg;
3434
*--sp = 0xdeadbeef;
3535

36-
regs.regs[1] = (uint64_t)sp;
36+
regs.regs[RSP] = (uint64_t)sp;
3737
regs.ip = (uint64_t)f;
3838
}

src/rt/arch/x86_64/context.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct registers_t {
2727

2828
class context {
2929
public:
30+
static const int RSP = 1;
31+
3032
registers_t regs;
3133

3234
context();
@@ -42,7 +44,7 @@ class context {
4244
// function being called causes the task to fail, then we have to avoid
4345
// leaking space on the C stack.
4446
inline void *alloc_stack(size_t nbytes) {
45-
uint32_t bot = regs.esp;
47+
uint32_t bot = regs.regs[RSP];
4648
uint32_t top = align_down(bot - nbytes);
4749

4850
#ifdef HAVE_VALGRIND

0 commit comments

Comments
 (0)