Skip to content

Commit

Permalink
Merge pull request #47 from allanlw/uopt
Browse files Browse the repository at this point in the history
Test user mode optimization settings in all_opts.sh
  • Loading branch information
gsilvis authored Jul 30, 2017
2 parents 71b521d + c872ec8 commit e558da2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ KERNEL_OPT += -g
#KERNEL_OPT += -flto
endif

ifeq ($(origin USER_OPT), undefined)
USER_OPT := -O2
endif

KERN_CFLAGS := -ffreestanding -mno-red-zone -Wall -Wextra -std=c99 -mno-mmx -mno-sse -mno-sse2 -mcmodel=kernel $(KERNEL_OPT)
KERN_LDFLAGS := -nostdlib -lgcc -Wl,-z,max-page-size=0x1000 -mcmodel=kernel -mno-mmx -mno-sse -mno-sse2 $(KERNEL_OPT)

BOOTLOADER_CFLAGS := -ffreestanding -mno-red-zone -Wall -Wextra -std=c99 -O2 -g
BOOTLOADER_LDFLAGS := -nostdlib -Wl,--no-warn-mismatch -Wl,-z,max-page-size=0x1000

USER_CFLAGS := -ffreestanding -Wall -Wextra -Wno-main -std=c99 -O2
USER_LDFLAGS := -nostdlib -lgcc
USER_CFLAGS := -ffreestanding -Wall -Wextra -Wno-main -std=c99 $(USER_OPT)
USER_LDFLAGS := -nostdlib -lgcc $(USER_OPT)

TEST_CFLAGS := -std=c99 -Wall -Wextra -DUNIT_TEST -Ikernel

Expand Down
9 changes: 5 additions & 4 deletions script/all_opts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

set -eu

for oflag in -O0 -O1 -O2 -O3 -Os; do
for ltoflag in -flto ''; do
KERNEL_OPT="$oflag -g $ltoflag " make clean test
done
for oflag in '-O0' '-O2' '-O3' '-O3 -flto'; do
for uoflag in -O0 -O2; do
make clean
USER_OPT="$uoflag" KERNEL_OPT="$oflag -g" make -j $(nproc) test
done
done
2 changes: 2 additions & 0 deletions userland/test-fork/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ int test_fork() {
DEBUG("Fork failed!");
exit();
} else if (ret == 0) {
/* Temporary fix to flakiness in this test */
nanosleep(1000);
++depth;
char child_msg[] = "Child, depth 0";
child_msg[sizeof(child_msg)-2] = '0' + depth;
Expand Down
4 changes: 2 additions & 2 deletions userland/test-memory/main.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "userland.h"
#define DEBUG(str) debug(str, sizeof(str))

inline unsigned char* getpage(unsigned int i) {
static inline unsigned char* getpage(unsigned int i) {
return (unsigned char*) ((1 << i) * 4096L);
}

inline unsigned char getent(unsigned int i, unsigned int j, int pid) {
static inline unsigned char getent(unsigned int i, unsigned int j, int pid) {
return ((i * 37) ^ j ^ pid) & 0xff;
}

Expand Down

0 comments on commit e558da2

Please sign in to comment.