Skip to content

Commit

Permalink
Move the dev-minded CFLAGS into the run-tests
Browse files Browse the repository at this point in the history
This removes debugging (-g) and warning (-W) flags in a default
invocation of pallenec. Again, the main reason is to pave the road for
the Luarocks compilation backend, which requires that any custom flags
be passed via the CFLAGS environment variable. However, I think it is
still a good idea despite that. Removing -g leads to smaller binaries
and faster compilation times. As for the warning-related flags, they are
not relevant to Pallene end-users, they are only relevant to us who are
writing the compiler.
  • Loading branch information
hugomg committed May 26, 2022
1 parent e89d7d7 commit 44ae7e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ echo "--- Test Suite ---"
# need to press Ctrl-C once and busted usually gets to exit gracefully.
FLAGS=(--verbose --no-keep-going)

# To speed things up, we tell the C compiler to skip optimizations.
# Don't worry, the continuous integration server still tests with optimizations.
export CFLAGS=-O0
# To speed things up, we tell the C compiler to skip optimizations. (It's OK, the CI still uses -O2)
# Also, add some compiler flags to verify standard compliance.
export CFLAGS='-O0 -std=c99 -Wall -Werror -Wundef -Wpedantic -Wno-unused'

if [ "$#" -eq 0 ]; then
if command -v parallel >/dev/null; then
Expand Down
13 changes: 4 additions & 9 deletions src/pallene/c_compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ local util = require "pallene.util"

local c_compiler = {}

local CC = "cc"
local CPPFLAGS = ""
local CFLAGS_BASE = "-std=c99 -g -fPIC -O2"
local CFLAGS_WARN = "-Wall -Wundef -Wpedantic -Wno-unused"
local USER_CFlAGS = os.getenv("CFLAGS") or ""
local CC = os.getenv("CC") or "cc"
local CFLAGS = os.getenv("CFLAGS") or "-O2"

local function get_uname()
local ok, err, uname = util.outputs_of_execute("uname -s")
Expand Down Expand Up @@ -49,10 +46,8 @@ end

function c_compiler.compile_c_to_o(in_filename, out_filename)
return run_cc({
CPPFLAGS,
CFLAGS_BASE,
CFLAGS_WARN,
USER_CFlAGS,
"-fPIC",
CFLAGS,
"-x c",
"-o", util.shell_quote(out_filename),
"-c", util.shell_quote(in_filename),
Expand Down

0 comments on commit 44ae7e8

Please sign in to comment.