Skip to content

Commit

Permalink
Support compiling for windows via MSVC
Browse files Browse the repository at this point in the history
- Add build system configuration for MSVC
- Replace gcc-specific attributes/builtins with macros
- Add dummy members to empty structs
- Replace ranged case statements (... syntax) with explict enumeration
- Replace variable-length arrays with constant-length
- Add alternate declarations of DIP macros, which require different
  varargs syntax
- Inline a couple of __func__ references with the actual name of the
  current function
- host_generic_regs.c: use memset to initial RRegUniverse
- tilegx: replace a couple instances of very strange syntax I don't
  fully understand
- When defining host-specific macros, use _WIN32 and _WIN64 to
  additionally detect x86/x64 platforms (TODO: handle ARM windows)
  • Loading branch information
rhelmot committed Mar 16, 2017
1 parent b773fc6 commit 4bdf4da
Show file tree
Hide file tree
Showing 31 changed files with 848 additions and 218 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,6 +3,7 @@
*.so
*.lib
*.dll
*.exe
vex

auxprogs/genoffsets
Expand Down
50 changes: 50 additions & 0 deletions Makefile-msvc
@@ -0,0 +1,50 @@
!include common.mk

##
## Step 1: A bunch of defines
##

!if "$(MULTIARCH)" == "1"
LIB_OBJS = $(NORMAL_OBJS) $(MULTIARCH_OBJS)
!else
LIB_OBJS = $(NORMAL_OBJS) $(MULTIARCH_OBJS)
!endif

CC = cl
CC_NATIVE = cl
AR = lib
RM = del /F

STATIC_LIBRARY_FILE = libvex.lib
DYNAMIC_LIBRARY_FILE = libvex.dll
EXTRA_CLEAN_FILES = auxprogs/genoffsets.exe genoffsets.obj

CCFLAGS = /Ipub /Ipriv $(EXTRA_CFLAGS) /O2 /wd4715

all: vex

$(STATIC_LIBRARY_FILE): $(LIB_OBJS)
$(AR) -OUT:libvex.lib $(LIB_OBJS)

$(DYNAMIC_LIBRARY_FILE): $(LIB_OBJS)
@echo "Currently, we don't build libvex.dll."
@echo "Doing so would require assembling a list of export symbols."


pub\libvex_guest_offsets.h: $(PUB_HEADERS) auxprogs/genoffsets.c
$(CC_NATIVE) $(CCFLAGS) auxprogs\genoffsets.c \
/Fo:auxprogs\genoffsets.o /Fe:auxprogs\genoffsets.exe
auxprogs\genoffsets.exe > pub\libvex_guest_offsets.h

.SUFFIXES: .o .c
.c.o:
$(CC) /Fo:$@ -c $< $(CCFLAGS)

scratch: clean all

vex: $(STATIC_LIBRARY_FILE) $(DYNAMIC_LIBRARY_FILE) $(GEN_HEADERS:/=\)

clean:
$(RM) $(GEN_HEADERS:/=\) $(NORMAL_OBJS:/=\) $(SINGLEARCH_OBJS:/=\) $(MULTIARCH_OBJS:/=\) \
$(STATIC_LIBRARY_FILE:/=\) $(DYNAMIC_LIBRARY_FILE:/=\) \
$(EXTRA_CLEAN_FILES:/=\)
3 changes: 0 additions & 3 deletions common.mk
Expand Up @@ -3,9 +3,6 @@
# - EXTRA_CFLAGS: exactly what it says on the tin
# - DEBUG: set to 1 to disable optimization and enable debug symbols

# initial target - result of running 'make'
all: vex

# These headers are autogenerated
GEN_HEADERS = pub/libvex_guest_offsets.h

Expand Down

0 comments on commit 4bdf4da

Please sign in to comment.