Giter Site home page Giter Site logo

99c's Introduction

github.com/cznic/99c has moved to modernc.org/99c (vcs).

Please update your import paths to modernc.org/99c.

This repo is now archived.

99c's People

Contributors

cznic avatar mattn avatar myitcv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

99c's Issues

zopfli: fails on non-empty input file

@opennota

jnml@r550:~/src/github.com/google/zopfli$ ls
CONTRIBUTING.md  CONTRIBUTORS  COPYING  Makefile  README  README.zopflipng  src
jnml@r550:~/src/github.com/google/zopfli$ git status 
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
jnml@r550:~/src/github.com/google/zopfli$ touch tmp
jnml@r550:~/src/github.com/google/zopfli$ 99c src/zopfli/*.c -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -lm -o zopfli && ./zopfli -v tmp
Saving to: tmp.gz
Error: Out of memory. Tried allocating 0 bytes of memory.
jnml@r550:~/src/github.com/google/zopfli$ 99trace ./zopfli -v tmp |& tee trace
jnml@r550:~/src/github.com/google/zopfli$

This looks like a bug in ccir or virtual. I'll try to invstigate later. Feel free to try to find the bug(s) by yourself if you like. The attached trace might be useful in identifying the source of the problem.

trace.zip

github.com/google/zopfli: loader fail

With #6 fixed:

jnml@4670:~/src/github.com/google/zopfli/src/zopfli$ 99c *.c
99c: virtual.LoadMain: blocksplitter.c:244:25: TODO *func(uint64,*struct{})float64 -> func(uint64,*struct{})float64
goroutine 1 [running]:
runtime/debug.Stack(0xc420d86c80, 0x6767e0, 0xc4210efe30)
	/home/jnml/go/src/runtime/debug/stack.go:24 +0xa7
github.com/cznic/virtual.LoadMain.func1(0xc420d89970)
	/home/jnml/src/github.com/cznic/virtual/loader.go:2599 +0x6e
panic(0x6767e0, 0xc4210efe30)
	/home/jnml/go/src/runtime/panic.go:491 +0x283
github.com/cznic/virtual.(*loader).loadFunctionDefinition(0xc420ada120, 0x85, 0xc420caba40)
	/home/jnml/src/github.com/cznic/virtual/loader.go:1294 +0x1932d
github.com/cznic/virtual.(*loader).load(0xc420ada120, 0xad, 0x100)
	/home/jnml/src/github.com/cznic/virtual/loader.go:2509 +0x15d1
github.com/cznic/virtual.LoadMain(0xc4215a0000, 0xad, 0x100, 0x0, 0x0, 0x0)
	/home/jnml/src/github.com/cznic/virtual/loader.go:2605 +0x80
main.(*task).main(0xc420d89e80, 0x0, 0x0)
	/home/jnml/src/github.com/cznic/99c/main.go:506 +0x19a7
main.main()
	/home/jnml/src/github.com/cznic/99c/main.go:52 +0x151

jnml@4670:~/src/github.com/google/zopfli/src/zopfli$

unnamed struct is disabled in default

#include <windows.h>

int main(int argc, char* argv[]) {
  MessageBox(0, "foo", "bar", MB_OK);
  return 0;
}

This make error

c:\dev\godev\src\github.com\cznic\ccir\libc\windows_windows_amd64.h:1874:3: unnamed fields not allowed

This seems to be enabled with cc.EnableAnonymousStructFields() but if I add this option into 99c/main.go, TODO error occured.

diff --git a/main.go b/main.go
index 7edb065..5c2e01f 100644
--- a/main.go
+++ b/main.go
@@ -196,6 +196,7 @@ func (t *task) main() error {
 			model,
 			cc.IncludePaths(t.args.I),
 			cc.SysIncludePaths([]string{ccir.LibcIncludePath}),
+			cc.EnableAnonymousStructFields(),
 			cc.AllowCompatibleTypedefRedefinitions(),
 			cc.Cpp(func(toks []xc.Token) {
 				if len(toks) != 0 {
@@ -249,6 +250,7 @@ func (t *task) main() error {
 				model,
 				cc.IncludePaths(t.args.I),
 				cc.SysIncludePaths([]string{ccir.LibcIncludePath}),
+				cc.EnableAnonymousStructFields(),
 				cc.AllowCompatibleTypedefRedefinitions(),
 			)
 			if err != nil {
@@ -297,6 +299,7 @@ func (t *task) main() error {
 			model,
 			cc.IncludePaths(t.args.I),
 			cc.SysIncludePaths([]string{ccir.LibcIncludePath}),
+			cc.EnableAnonymousStructFields(),
 			cc.AllowCompatibleTypedefRedefinitions(),
 		)
 		if err != nil {
99c: PANIC: c:\dev\godev\src\github.com\cznic\ccir\libc\windows_windows_amd64.h:2456:9: TODO
goroutine 1 [running]:
runtime/debug.Stack(0xc042cdc7b8, 0x65e460, 0xc04300ed70)
	c:/dev/go/src/runtime/debug/stack.go:24 +0xae
main.main.func1()
	c:/dev/godev/src/github.com/cznic/99c/main.go:34 +0x67
panic(0x65e460, 0xc04300ed70)
	c:/dev/go/src/runtime/panic.go:502 +0x274
github.com/cznic/cc.(*StructOrUnionSpecifier).isCompatible(0xc043027680, 0xc043027620, 0x1c930)
	c:/dev/godev/src/github.com/cznic/cc/ast2.go:3397 +0x79f
github.com/cznic/cc.(*Bindings).defineStructTag(0xc0421fc090, 0x154000000e021, 0x1c930, 0x6eafa0, 0xc043027680, 0xc0421e20c0)
	c:/dev/godev/src/github.com/cznic/cc/etc.go:422 +0x175
github.com/cznic/cc.yyParse(0x6eb700, 0xc04206ac00, 0x0)
	c:/dev/godev/src/github.com/cznic/cc/parser.go:3841 +0xd528
github.com/cznic/cc.Parse(0xc042199090, 0x45, 0xc0421ccac0, 0x2, 0x2, 0xc0421f2000, 0xc042069d20, 0x4, 0x4, 0x32, ...)
	c:/dev/godev/src/github.com/cznic/cc/cc.go:808 +0x692
main.(*task).main(0xc042cddec0, 0x0, 0x0)
	c:/dev/godev/src/github.com/cznic/99c/main.go:291 +0x13c1
main.main()
	c:/dev/godev/src/github.com/cznic/99c/main.go:40 +0xb2

:**

libxcb-1.12: missing builtins

jnml@4670:~/libxcb-1.12$ CC=99c ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for a Python interpreter with version >= 2.6... python
checking for python... /usr/bin/python
checking for python version... 2.7
checking for python platform... linux2
checking for python script directory... ${prefix}/lib/python2.7/dist-packages
checking for python extension module directory... ${exec_prefix}/lib/python2.7/dist-packages
checking for style of include used by make... GNU
checking for gcc... 99c
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... no
checking whether 99c accepts -g... yes
checking for 99c option to accept ISO C89... none needed
checking whether 99c understands -c and -o together... no
checking dependency style of /home/jnml/libxcb-1.12/build-aux/compile 99c... none
checking how to run the C preprocessor... /lib/cpp
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... no
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... no
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for non-GNU ld... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from /home/jnml/libxcb-1.12/build-aux/compile 99c object... failed
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking for /home/jnml/libxcb-1.12/build-aux/compile 99c option to produce PIC...  -DPIC
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c PIC flag  -DPIC works... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c static flag  works... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -c -o file.o... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -c -o file.o... (cached) yes
checking whether the /home/jnml/libxcb-1.12/build-aux/compile 99c linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for /home/jnml/libxcb-1.12/build-aux/compile 99c option to accept ISO C99... unsupported
checking whether __clang__ is declared... no
checking whether __INTEL_COMPILER is declared... no
checking whether __SUNPRO_C is declared... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=unknown-warning-option... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=unused-command-line-argument... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wall... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wpointer-arith... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wmissing-declarations... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wformat=2... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wstrict-prototypes... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wmissing-prototypes... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wnested-externs... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wbad-function-cast... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wold-style-definition... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wdeclaration-after-statement... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wunused... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wuninitialized... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wshadow... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wmissing-noreturn... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wmissing-format-attribute... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wredundant-decls... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Wlogical-op... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=implicit... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=nonnull... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=init-self... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=main... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=missing-braces... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=sequence-point... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=return-type... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=trigraphs... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=array-bounds... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=write-strings... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=address... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=int-to-pointer-cast... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=pointer-to-int-cast... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -pedantic... no
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror... yes
checking if /home/jnml/libxcb-1.12/build-aux/compile 99c supports -Werror=attributes... yes
Package xorg-macros was not found in the pkg-config search path.
Perhaps you should add the directory containing `xorg-macros.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xorg-macros' found
checking whether make supports nested variables... (cached) yes
checking whether to build developer documentation... yes
checking for doxygen... no
configure: WARNING: doxygen not found - documentation targets will be skipped
configure: WARNING: dot not found - doxygen targets will be skipped
checking for CHECK... no
checking for XCBPROTO... yes
checking for NEEDED... yes
checking for XDMCP... yes
checking for XdmcpWrap in -lXdmcp... no
checking XCBPROTO_XCBINCLUDEDIR... /usr/share/xcb
checking XCBPROTO_XCBPYTHONDIR... /usr/lib/python2.7/dist-packages
checking for ANSI C header files... (cached) no
checking for library containing getaddrinfo... no
checking for library containing connect... no
checking for library containing sendmsg... no
checking for struct msghdr.msg_control... yes
checking for struct sockaddr_un.sun_len... no
checking tsol/label.h usability... no
checking tsol/label.h presence... no
checking for tsol/label.h... no
checking for is_system_labeled... no
checking whether IOV_MAX is declared... no
checking whether UIO_MAXIOV is declared... yes
checking whether /home/jnml/libxcb-1.12/build-aux/compile 99c supports symbol visibility... no
checking for getaddrinfo... no
checking for poll... no
checking for launchd... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating man/Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating xcb.pc
config.status: creating xcb-composite.pc
config.status: creating xcb-damage.pc
config.status: creating xcb-dpms.pc
config.status: creating xcb-dri2.pc
config.status: creating xcb-dri3.pc
config.status: creating xcb-glx.pc
config.status: creating xcb-present.pc
config.status: creating xcb-randr.pc
config.status: creating xcb-record.pc
config.status: creating xcb-render.pc
config.status: creating xcb-res.pc
config.status: creating xcb-screensaver.pc
config.status: creating xcb-shape.pc
config.status: creating xcb-shm.pc
config.status: creating xcb-sync.pc
config.status: creating xcb-xevie.pc
config.status: creating xcb-xf86dri.pc
config.status: creating xcb-xfixes.pc
config.status: creating xcb-xinerama.pc
config.status: creating xcb-xinput.pc
config.status: creating xcb-xkb.pc
config.status: creating xcb-xprint.pc
config.status: creating xcb-xselinux.pc
config.status: creating xcb-xtest.pc
config.status: creating xcb-xv.pc
config.status: creating xcb-xvmc.pc
config.status: creating doc/xcb.doxygen
config.status: creating src/config.h
config.status: executing depfiles commands
config.status: executing libtool commands

  Package: libxcb 1.12

  Configuration
    XDM support.........: no
    sendmsg fd passing..: no
    Build unit tests....: no
      with html results.: no
    XCB buffer size.....: 16384

  X11 extensions
    Composite...........: yes
    Damage..............: yes
    Dpms................: yes
    Dri2................: yes
    Dri3................: no
    Glx.................: yes
    Randr...............: yes
    Record..............: yes
    Render..............: yes
    Resource............: yes
    Screensaver.........: yes
    selinux.............: no
    Shape...............: yes
    Shm.................: yes
    Sync................: yes
    Xevie...............: no
    Xfixes..............: yes
    Xfree86-dri.........: yes
    xinerama............: yes
    xinput..............: no
    xkb.................: yes
    xprint..............: no
    xtest...............: yes
    xv..................: yes
    xvmc................: yes

  Used CFLAGS:
    CPPFLAGS............: 
    CFLAGS..............: -g

  Installation:
    Prefix..............: /usr/local

jnml@4670:~/libxcb-1.12$ CC=99c make
Making all in src
make[1]: Vstupuje se do adresáře „/home/jnml/libxcb-1.12/src“
  GEN      xproto.c
  GEN      bigreq.c
  GEN      xc_misc.c
  GEN      composite.c
  GEN      damage.c
  GEN      dpms.c
  GEN      dri2.c
  GEN      dri3.c
  GEN      present.c
  GEN      glx.c
  GEN      randr.c
  GEN      record.c
  GEN      render.c
  GEN      res.c
  GEN      screensaver.c
  GEN      shape.c
  GEN      shm.c
  GEN      sync.c
  GEN      xevie.c
  GEN      xf86dri.c
  GEN      xfixes.c
  GEN      xinerama.c
  GEN      xinput.c
  GEN      xkb.c
  GEN      xprint.c
  GEN      xselinux.c
  GEN      xtest.c
  GEN      xv.c
  GEN      xvmc.c
make  all-am
make[2]: Vstupuje se do adresáře „/home/jnml/libxcb-1.12/src“
  CC       xcb_conn.lo
  CC       xcb_out.lo
  CC       xcb_in.lo
  CC       xcb_ext.lo
  CC       xcb_xid.lo
  CC       xcb_list.lo
  CC       xcb_util.lo
  CC       xcb_auth.lo
  CC       xproto.lo
  CC       bigreq.lo
  CC       xc_misc.lo
  CCLD     libxcb.la
99c: xcb_conn.c:456:5: ir.linker undefined external global __FD_ZERO
Makefile:934: návod pro cíl „libxcb.la“ selhal
make[2]: *** [libxcb.la] Chyba 1
make[2]: Opouští se adresář „/home/jnml/libxcb-1.12/src“
Makefile:771: návod pro cíl „all“ selhal
make[1]: *** [all] Chyba 2
make[1]: Opouští se adresář „/home/jnml/libxcb-1.12/src“
Makefile:788: návod pro cíl „all-recursive“ selhal
make: *** [all-recursive] Chyba 1
jnml@4670:~/libxcb-1.12$ 

examples/fib: link error

This works

jnml@4670:~/src/github.com/cznic/99c$ cd examples/prof/
/home/jnml/src/github.com/cznic/99c/examples/prof
jnml@4670:~/src/github.com/cznic/99c/examples/prof$ ls *
bogomips.c  fib.c
jnml@4670:~/src/github.com/cznic/99c/examples/prof$ 99c fib.c && 99dump a.out
virtual.Binary a.out: code 0x0006a, text 0x00010, data 0x00060, bss 0x00020, pc2func 3, pc2line 27
0x00000		call           0x2	; -
0x00001		ffireturn      		; -

# _start
0x00002	func	; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:13:1
0x00003		arguments      			; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00004		push64         (ds)		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00005		push64         (ds+0x10)	; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00006		push64         (ds+0x20)	; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00007		#register_stdfiles		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00008		arguments      			; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x00009		sub            sp, 0x8		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000a		arguments      			; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000b		push32         (ap-0x8)		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000c		push64         (ap-0x10)	; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000d		call           0x16		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000e		#exit          			; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1

0x0000f		builtin        		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:16:1
0x00010		#register_stdfiles	; __register_stdfiles:89:1
0x00011		ffireturn      		; __register_stdfiles:89:1

0x00012		add            sp, 0x8	; __builtin_exit:86:1
0x00013		#exit          		; __builtin_exit:86:1

0x00014		call           0x16	; __builtin_exit:86:1
0x00015		ffireturn      		; __builtin_exit:86:1

# main
0x00016	func	variables      [0x8]byte	; fib.c:17:1
0x00017		push           ap		; fib.c:17:1
0x00018		zero32         			; fib.c:17:1
0x00019		store32        			; fib.c:17:1
0x0001a		add            sp, 0x8		; fib.c:17:1
0x0001b		push32         (ap-0x8)		; fib.c:18:1
0x0001c		push32         0x2		; fib.c:18:1
0x0001d		neqi32         			; fib.c:18:1
0x0001e		jz             0x23		; fib.c:18:1

0x0001f		push           ap	; fib.c:19:1
0x00020		push32         0x2	; fib.c:19:1
0x00021		store32        		; fib.c:19:1
0x00022		return         		; fib.c:19:1

0x00023		push           bp-0x8		; fib.c:18:1
0x00024		sub            sp, 0x8		; fib.c:22:1
0x00025		arguments      			; fib.c:22:1
0x00026		push64         (ap-0x10)	; fib.c:22:1
0x00027		push32         0x1		; fib.c:22:1
0x00028		indexi32       0x8		; fib.c:22:1
0x00029		load64         0x0		; fib.c:22:1
0x0002a		#atoi          			; fib.c:22:1
0x0002b		store32        			; fib.c:22:1
0x0002c		add            sp, 0x8		; fib.c:22:1
0x0002d		push32         0x1		; fib.c:23:1
0x0002e		push32         (bp-0x8)		; fib.c:23:1
0x0002f		zero32         			; fib.c:23:1
0x00030		leqi32         			; fib.c:23:1
0x00031		jnz            0x38		; fib.c:23:1

0x00032		push32         (bp-0x8)	; fib.c:23:1
0x00033		push32         0x28	; fib.c:23:1
0x00034		gti32          		; fib.c:23:1
0x00035		jnz            0x38	; fib.c:23:1

0x00036		add            sp, 0x8	; fib.c:23:1
0x00037		zero32         		; fib.c:23:1
0x00038		jz             0x3d	; fib.c:23:1

0x00039		push           ap	; fib.c:24:1
0x0003a		push32         0x1	; fib.c:24:1
0x0003b		store32        		; fib.c:24:1
0x0003c		return         		; fib.c:24:1

0x0003d		sub            sp, 0x8	; fib.c:23:1
0x0003e		arguments      		; fib.c:27:1
0x0003f		push           ts+0x0	; fib.c:27:1
0x00040		sub            sp, 0x8	; fib.c:27:1
0x00041		arguments      		; fib.c:27:1
0x00042		push32         (bp-0x8)	; fib.c:27:1
0x00043		call           0x4e	; fib.c:27:1
0x00044		#printf        		; fib.c:27:1
0x00045		return         		; fib.c:27:1

0x00046		builtin        	; fib.c:28:1
0x00047		#atoi          	; atoi:69:1
0x00048		ffireturn      	; atoi:69:1

0x00049		builtin        	; printf:253:1
0x0004a		#printf        	; printf:253:1
0x0004b		ffireturn      	; printf:253:1

0x0004c		call           0x4e	; printf:253:1
0x0004d		ffireturn      		; printf:253:1

# fib
0x0004e	func	; fib.c:5:1
0x0004f		push32         (ap-0x8)	; fib.c:6:1
0x00050		switchi32      ds+0x30	; fib.c:6:1
0x00051		push           ap	; fib.c:7:1
0x00052		zero32         		; fib.c:8:1
0x00053		store32        		; fib.c:8:1
0x00054		return         		; fib.c:8:1

0x00055		push           ap	; fib.c:9:1
0x00056		push32         0x1	; fib.c:10:1
0x00057		store32        		; fib.c:10:1
0x00058		return         		; fib.c:10:1

0x00059		push           ap	; fib.c:11:1
0x0005a		sub            sp, 0x8	; fib.c:12:1
0x0005b		arguments      		; fib.c:12:1
0x0005c		push32         (ap-0x8)	; fib.c:12:1
0x0005d		push32         0x1	; fib.c:12:1
0x0005e		subi32         		; fib.c:12:1
0x0005f		call           0x4e	; fib.c:12:1
0x00060		sub            sp, 0x8	; fib.c:12:1
0x00061		arguments      		; fib.c:12:1
0x00062		push32         (ap-0x8)	; fib.c:12:1
0x00063		push32         0x2	; fib.c:12:1
0x00064		subi32         		; fib.c:12:1
0x00065		call           0x4e	; fib.c:12:1
0x00066		addi32         		; fib.c:12:1
0x00067		store32        		; fib.c:12:1
0x00068		return         		; fib.c:12:1

0x00069		return         	; fib.c:14:1

Text segment
00000000  25 69 0a 00 00 00 00 00  00 00 00 00 00 00 00 00  |%i..............|

Data segment
00000000  60 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |`...............|
00000010  68 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |h...............|
00000020  70 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |p...............|
00000030  02 00 00 00 00 00 00 00  00 00 00 00 01 00 00 00  |................|
00000040  51 00 00 00 00 00 00 00  55 00 00 00 00 00 00 00  |Q.......U.......|
00000050  59 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |Y...............|

DS relative bitvector
00000000  01 00 01 00 01                                    |.....|

Symbol table
0x00012	function	__builtin_exit
0x0000f	function	__register_stdfiles
0x00000	function	_start
0x00046	function	atoi
0x0004c	function	fib
0x00014	function	main
0x00049	function	printf

This does not

jnml@4670:~/src/github.com/cznic/99c/examples/prof$ 99c -c fib.c && 99c fib.o && 99dump a.out
virtual.Binary a.out: code 0x00041, text 0x00000, data 0x00030, bss 0x00020, pc2func 2, pc2line 15
0x00000		call           0x2	; -
0x00001		ffireturn      		; -

# _start
0x00002	func	; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:13:1
0x00003		arguments      			; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00004		push64         (ds)		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00005		push64         (ds+0x10)	; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00006		push64         (ds+0x20)	; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00007		#register_stdfiles		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:14:1
0x00008		arguments      			; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x00009		sub            sp, 0x8		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000a		arguments      			; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000b		push32         (ap-0x8)		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000c		push64         (ap-0x10)	; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000d		call           0x16		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1
0x0000e		#exit          			; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:15:1

0x0000f		builtin        		; /home/jnml/src/github.com/cznic/ccir/libc/crt0.c:16:1
0x00010		#register_stdfiles	; __register_stdfiles:89:1
0x00011		ffireturn      		; __register_stdfiles:89:1

0x00012		add            sp, 0x8	; __builtin_exit:86:1
0x00013		#exit          		; __builtin_exit:86:1

0x00014		call           0x16	; __builtin_exit:86:1
0x00015		ffireturn      		; __builtin_exit:86:1

# main
0x00016	func	variables      [0x8]byte	; fib.c:17:1
0x00017		push           ap		; fib.c:17:1
0x00018		zero32         			; fib.c:17:1
0x00019		store32        			; fib.c:17:1
0x0001a		add            sp, 0x8		; fib.c:17:1
0x0001b		push32         (ap-0x8)		; fib.c:18:1
0x0001c		push32         0x2		; fib.c:18:1
0x0001d		neqi32         			; fib.c:18:1
0x0001e		jz             0x23		; fib.c:18:1

0x0001f		push           ap	; fib.c:19:1
0x00020		push32         0x2	; fib.c:19:1
0x00021		store32        		; fib.c:19:1
0x00022		return         		; fib.c:19:1

0x00023		push           bp-0x8		; fib.c:18:1
0x00024		sub            sp, 0x8		; fib.c:22:1
0x00025		arguments      			; fib.c:22:1
0x00026		push64         (ap-0x10)	; fib.c:22:1
0x00027		push32         0x1		; fib.c:22:1
0x00028		indexi32       0x8		; fib.c:22:1
0x00029		load64         0x0		; fib.c:22:1
0x0002a		#atoi          			; fib.c:22:1
0x0002b		store32        			; fib.c:22:1
0x0002c		add            sp, 0x8		; fib.c:22:1
0x0002d		push32         0x1		; fib.c:23:1
0x0002e		push32         (bp-0x8)		; fib.c:23:1
0x0002f		zero32         			; fib.c:23:1
0x00030		leqi32         			; fib.c:23:1
0x00031		jnz            0x38		; fib.c:23:1

0x00032		push32         (bp-0x8)	; fib.c:23:1
0x00033		push32         0x28	; fib.c:23:1
0x00034		gti32          		; fib.c:23:1
0x00035		jnz            0x38	; fib.c:23:1

0x00036		add            sp, 0x8	; fib.c:23:1
0x00037		zero32         		; fib.c:23:1
0x00038		jz             0x23	; fib.c:23:1

0x00039		push           ap	; fib.c:24:1
0x0003a		push32         0x1	; fib.c:24:1
0x0003b		store32        		; fib.c:24:1
0x0003c		return         		; fib.c:24:1

0x0003d		return         	; fib.c:28:1

0x0003e		builtin        	; atoi:69:1
0x0003f		#atoi          	; atoi:69:1
0x00040		ffireturn      	; atoi:69:1

Data segment
00000000  30 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |0...............|
00000010  38 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |8...............|
00000020  40 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |@...............|

DS relative bitvector
00000000  01 00 01 00 01                                    |.....|

Symbol table
0x00012	function	__builtin_exit
0x0000f	function	__register_stdfiles
0x00000	function	_start
0x0003e	function	atoi
0x00014	function	main
jnml@4670:~/src/github.com/cznic/99c/examples/prof$ 

The later approach produces a corrupted binary missing the fib function.

99c: mismatched types, got *[2]*struct{...}, expected **struct{...}

@opennota Fixing #5 unearthed another error:

$ cd $GOPATH/src/github.com/google/zopfli/src/zopfli
$ 99c *.c
99c: mismatched types, got *[2]*struct{weight uint64,tail *struct{},count int32}, expected **struct{weight uint64,tail *struct{},count int32}
ZopfliLengthLimitedCodeLengths:0x14a: 	convert         	**struct{weight uint64,tail *struct{},count int32}, *[2]*struct{weight uint64,tail *struct{},count int32}	; katajainen.c:246:37
$ 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.