Skip to content

Commit

Permalink
Add cgo2c program to translate mixed Go/C code into C. This
Browse files Browse the repository at this point in the history
lets us use a single source file for both 6c and gcc, handling
the incompatible handling of return values.

R=rsc
DELTA=649  (613 added, 35 deleted, 1 changed)
OCL=22682
CL=22730
  • Loading branch information
ianlancetaylor committed Jan 14, 2009
1 parent 58b280d commit 2b57a11
Show file tree
Hide file tree
Showing 5 changed files with 619 additions and 36 deletions.
10 changes: 9 additions & 1 deletion src/runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ LIBOFILES=\
array.$O\
mem.$O\
malloc.$O\
malloc_go.$O\
mcache.$O\
mcentral.$O\
mfixalloc.$O\
Expand Down Expand Up @@ -57,14 +58,21 @@ nuke:
rm -f *.$(O) *.a $(GOROOT)/lib/$(LIB)

clean:
rm -f *.$(O) *.a runtime.acid
rm -f *.$(O) *.a runtime.acid cgo2c

%.$O: %.c
$(CC) -wF $<

sys_file.$O: sys_file.c sys_types.h $(OS_H)
$(CC) -wF -D$(GOARCH)_$(GOOS) $<

cgo2c: cgo2c.c
quietgcc -o $@ $<

%.c: %.cgo cgo2c
./cgo2c < $< > $@.tmp
mv -f $@.tmp $@

%.$O: %.s
$(AS) $<

Expand Down
Loading

0 comments on commit 2b57a11

Please sign in to comment.