Skip to content

Instantly share code, notes, and snippets.

@jeehoonkang
Created November 21, 2016 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeehoonkang/c7f93d6a8cfbd3c437829c87867e7e29 to your computer and use it in GitHub Desktop.
Save jeehoonkang/c7f93d6a8cfbd3c437829c87867e7e29 to your computer and use it in GitHub Desktop.
xv6-public.diff
diff --git a/Makefile b/Makefile
index 93d525a..db07442 100644
--- a/Makefile
+++ b/Makefile
@@ -70,15 +70,16 @@ QEMU = $(shell if which qemu > /dev/null; \
echo "***" 1>&2; exit 1)
endif
-CC = $(TOOLPREFIX)gcc
+CC = $(TOOLPREFIX)clang
+GCC = $(TOOLPREFIX)gcc
AS = $(TOOLPREFIX)gas
LD = $(TOOLPREFIX)ld
OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump
-CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer
+CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -Wno-gnu-designator -fno-omit-frame-pointer
#CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -fvar-tracking -fvar-tracking-assignments -O0 -g -Wall -MD -gdwarf-2 -m32 -Werror -fno-omit-frame-pointer
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
-ASFLAGS = -m32 -gdwarf-2 -Wa,-divide
+ASFLAGS = -m32 -gdwarf-2
# FreeBSD ld wants ``elf_i386_fbsd''
LDFLAGS += -m $(shell $(LD) -V | grep elf_i386 2>/dev/null | head -n 1)
@@ -93,8 +94,8 @@ xv6memfs.img: bootblock kernelmemfs
dd if=kernelmemfs of=xv6memfs.img seek=1 conv=notrunc
bootblock: bootasm.S bootmain.c
- $(CC) $(CFLAGS) -fno-pic -O -nostdinc -I. -c bootmain.c
- $(CC) $(CFLAGS) -fno-pic -nostdinc -I. -c bootasm.S
+ $(GCC) $(CFLAGS) -fno-pic -O -nostdinc -I. -c bootmain.c
+ $(GCC) $(CFLAGS) -fno-pic -nostdinc -I. -c bootasm.S
$(LD) $(LDFLAGS) -N -e start -Ttext 0x7C00 -o bootblock.o bootasm.o bootmain.o
$(OBJDUMP) -S bootblock.o > bootblock.asm
$(OBJCOPY) -S -O binary -j .text bootblock.o bootblock
@@ -149,7 +150,7 @@ _forktest: forktest.o $(ULIB)
$(OBJDUMP) -S _forktest > forktest.asm
mkfs: mkfs.c fs.h
- gcc -Werror -Wall -o mkfs mkfs.c
+ $(CC) -Werror -Wall -o mkfs mkfs.c
# Prevent deletion of intermediate files, e.g. cat.o, after first build, so
# that disk image changes after first build are persistent until clean. More
diff --git a/proc.c b/proc.c
index 7d03ad7..473fa88 100644
--- a/proc.c
+++ b/proc.c
@@ -470,7 +470,13 @@ procdump(void)
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state == UNUSED)
continue;
- if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
+ /* if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) */
+ /* */
+ /* proc.c:473:17: error: comparison of unsigned enum expression >= 0 is always true [-Werror,-Wtautological-compare] */
+ /* if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) */
+ /* ~~~~~~~~ ^ ~ */
+ /* 1 error generated. */
+ if(p->state < NELEM(states) && states[p->state])
state = states[p->state];
else
state = "???";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment