Commit Graph

40 Commits

Author SHA1 Message Date
Rui Ueyama 57c1d4ec02 Add -MP option 2020-12-07 12:00:06 +09:00
Rui Ueyama 95d5a46234 Add -MF option 2020-12-07 12:00:06 +09:00
Rui Ueyama d0c4667b6b Add -M option 2020-12-07 12:00:06 +09:00
Rui Ueyama 0aad326f35 Add string hashmap 2020-12-07 12:00:06 +09:00
Rui Ueyama d56dd2f46e Recognize .a and .so files 2020-12-07 12:00:06 +09:00
Rui Ueyama c32f0e21e7 Add -s option 2020-12-07 12:00:06 +09:00
Rui Ueyama bc2527944a Add -l option 2020-12-07 12:00:06 +09:00
Rui Ueyama 4064871212 Make -E to imply -xc 2020-12-07 12:00:06 +09:00
Rui Ueyama ee0a951b30 Add -x option 2020-12-07 12:00:06 +09:00
Rui Ueyama 8f5ff07dc0 Add -include option 2020-12-07 12:00:06 +09:00
Rui Ueyama 6d344ed945 Add -fcommon and -fno-common flags 2020-12-07 12:00:06 +09:00
Rui Ueyama 11fc259b01 Add -idirafter option 2020-12-07 12:00:06 +09:00
Rui Ueyama b1fdddff15 Ignore -O, -W and -g and other flags 2020-12-07 12:00:06 +09:00
Rui Ueyama 2bdc6b800c Write to an in-memory buffer before writing to an actual output file
We don't want to leave a partial assembly output if the compiler
fails during compilation.

Technically speaking, there's still a risk of leaving a partially-
written output file if the compiler dies during file copy. To fix
that, we have to write to a temporary file in the same filesystem as
the final output file and rename the temporary file to atomically
replace the output file. We don't do that in this patch for the sake
of succinctness, though.
2020-12-07 12:00:06 +09:00
Rui Ueyama be8b6f6d31 Add -U option 2020-12-07 12:00:06 +09:00
Rui Ueyama fc69f5c6f9 Add -D option 2020-12-07 12:00:06 +09:00
Rui Ueyama a939a7a906 Add default include paths 2020-12-07 12:00:06 +09:00
Rui Ueyama a1dd6213c8 Add -I<dir> option 2020-12-07 12:00:06 +09:00
Rui Ueyama d85fc4ffcf Add #include <...> 2020-12-07 12:00:06 +09:00
Rui Ueyama dec3b3fa02 Add zero-arity funclike #define 2020-12-07 12:00:06 +09:00
Rui Ueyama d138864a2a Add -E option 2020-12-07 12:00:06 +09:00
Rui Ueyama d367510fcc Add #include "..." 2020-12-07 12:00:06 +09:00
Rui Ueyama 1e1ea39dad Add a do-nothing preprocessor 2020-12-07 12:00:06 +09:00
Rui Ueyama 8b726b5489 Run "ld" unless -c is given 2020-12-07 12:00:06 +09:00
Rui Ueyama b833cd0f29 Accept multiple input files 2020-12-07 12:00:06 +09:00
Rui Ueyama 140b43358c Run "as" command unless -S is given 2020-12-07 12:00:06 +09:00
Rui Ueyama f3d96136f2 Split cc1 from compiler driver 2020-12-07 12:00:06 +09:00
Rui Ueyama 1c91d1943a Emit .file and .loc assembler directives
With these directives, gdb can print out an error location when
a compiled program crashes.
2020-10-15 14:22:16 +09:00
Rui Ueyama a0388bada4 Add -o and --help options 2020-10-08 16:23:53 +09:00
Rui Ueyama d9ea59757e Read code from a file instead of argv[1] 2020-10-08 16:23:49 +09:00
Rui Ueyama 0b7663481d Merge Function with Var
No functional change
2020-10-07 20:13:26 +09:00
Rui Ueyama 482c26b536 Support multi-letter local variables 2020-10-07 20:12:19 +09:00
Rui Ueyama 725badfb49 Split main.c into multiple small files 2020-10-07 20:11:16 +09:00
Rui Ueyama 25b4b85b88 Add ==, !=, <= and >= operators 2020-10-07 20:10:14 +09:00
Rui Ueyama bf9ab52860 Add unary plus and minus 2020-10-07 13:17:05 +09:00
Rui Ueyama 84cfcaf98f Add *, / and () 2020-10-07 13:17:05 +09:00
Rui Ueyama cc5a6d9781 Improve error message
Now, chibicc can print out an error message with an error location
like this:

  $ ./chibicc 1+foo
  1+foo
    ^ expected a number
2020-10-07 13:17:05 +09:00
Rui Ueyama a1ab0ff26f Add a tokenizer to allow space characters between tokens 2020-10-07 13:17:04 +09:00
Rui Ueyama bf7081fba7 Add + and - operators 2020-09-13 21:36:37 +09:00
Rui Ueyama 0522e2d77e Compile an integer to an exectuable that exits with the given number 2020-09-13 21:36:28 +09:00