Makefile, .gitignore, .editorconfig, configure, tests/cc-compat.sh: added configure script for compiler optimizations
This commit is contained in:
parent
622c13021d
commit
49a3bb9f30
|
@ -6,3 +6,6 @@ end_of_line = lf
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[configure]
|
||||||
|
indent_size = 2
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
|
*.mk
|
||||||
|
|
20
Makefile
20
Makefile
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (c) 2023 Emma Tebibyte <emma@tebibyte.media>
|
# Copyright (c) 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
||||||
# Copyright (c) 2023 DTB <trinity@trinity.moe>
|
# Copyright (c) 2023 DTB <trinity@trinity.moe>
|
||||||
# Copyright (c) 2023 Sasha Koshka <sashakoshka@tebibyte.media>
|
# Copyright (c) 2023 Sasha Koshka <sashakoshka@tebibyte.media>
|
||||||
# SPDX-License-Identifier: FSFAP
|
# SPDX-License-Identifier: FSFAP
|
||||||
|
@ -18,19 +18,17 @@
|
||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
|
|
||||||
CC=cc
|
CC=cc
|
||||||
CFLAGS=-O3 -Lbuild/lib -idirafter include
|
|
||||||
|
|
||||||
RUSTC=rustc
|
RUSTC=rustc
|
||||||
RUSTCFLAGS=-Copt-level=z -Ccodegen-units=1 -Cpanic=abort -Clto=y \
|
|
||||||
-Cstrip=symbols -Ctarget-cpu=native \
|
|
||||||
--extern sysexits=build/o/libsysexits.rlib
|
|
||||||
|
|
||||||
all: false fop intcmp scrut str strcmp true test
|
# to build, first run ./configure
|
||||||
|
include *.mk
|
||||||
|
|
||||||
|
all: false fop intcmp scrut str strcmp true
|
||||||
|
|
||||||
build:
|
build:
|
||||||
# keep build/include until bindgen(1) has stdin support
|
# keep build/include until bindgen(1) has stdin support
|
||||||
# https://github.com/rust-lang/rust-bindgen/issues/2703
|
# https://github.com/rust-lang/rust-bindgen/issues/2703
|
||||||
mkdir -p build/bin build/include build/o # build/lib
|
mkdir -p build/bin build/include build/o build/lib
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build/ dist/
|
rm -rf build/ dist/
|
||||||
|
@ -65,10 +63,10 @@ sysexits: build
|
||||||
| $(RUSTC) $(RUSTCFLAGS) --crate-type lib -o build/o/libsysexits.rlib -
|
| $(RUSTC) $(RUSTCFLAGS) --crate-type lib -o build/o/libsysexits.rlib -
|
||||||
|
|
||||||
false: src/false.rs build
|
false: src/false.rs build
|
||||||
$(RUSTC) $(RUSTCFLAGS) -o build/bin/false src/false.rs
|
$(RUSTC) $(RUSTFLAGS) -o build/bin/false src/false.rs
|
||||||
|
|
||||||
fop: src/fop.rs build sysexits
|
fop: src/fop.rs build sysexits
|
||||||
$(RUSTC) $(RUSTCFLAGS) -o build/bin/fop src/fop.rs
|
$(RUSTC) $(RUSTFLAGS) -o build/bin/fop src/fop.rs
|
||||||
|
|
||||||
intcmp: src/intcmp.c build
|
intcmp: src/intcmp.c build
|
||||||
$(CC) $(CFLAGS) -o build/bin/intcmp src/intcmp.c
|
$(CC) $(CFLAGS) -o build/bin/intcmp src/intcmp.c
|
||||||
|
@ -83,4 +81,4 @@ strcmp: src/strcmp.c build
|
||||||
$(CC) $(CFLAGS) -o build/bin/strcmp src/strcmp.c
|
$(CC) $(CFLAGS) -o build/bin/strcmp src/strcmp.c
|
||||||
|
|
||||||
true: src/true.rs build
|
true: src/true.rs build
|
||||||
$(RUSTC) $(RUSTCFLAGS) -o build/bin/true src/true.rs
|
$(RUSTC) $(RUSTFLAGS) -o build/bin/true src/true.rs
|
||||||
|
|
39
configure
vendored
Executable file
39
configure
vendored
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Copyright (c) 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
||||||
|
# SPDX-License-Identifier: FSFAP
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice and this
|
||||||
|
# notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
CFLAGS='-Lbuild/lib -idirafter include -O3'
|
||||||
|
RUSTFLAGS='-Copt-level=z -Ccodegen-units=1 -Cpanic=abort -Clto=y \
|
||||||
|
-Cstrip=symbols -Ctarget-cpu=native \
|
||||||
|
--extern sysexits=build/o/libsysexits.rlib'
|
||||||
|
|
||||||
|
case "$@" in
|
||||||
|
clang)
|
||||||
|
CFLAGS="$CFLAGS -Wall"
|
||||||
|
;;
|
||||||
|
clean)
|
||||||
|
rm *.mk || true
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
gcc)
|
||||||
|
CFLAGS="$CFLAGS -s -Wl,-z,noseparate-code,-z,nosectionheader -flto"
|
||||||
|
;;
|
||||||
|
'rustc +nightly')
|
||||||
|
RUSTFLAGS="+nightly -Zlocation-detail=none $RUSTFLAGS"
|
||||||
|
;;
|
||||||
|
'') ;;
|
||||||
|
*)
|
||||||
|
printf 'Usage: %s [compiler]\n' "$0"
|
||||||
|
exit 64 # sysexits.h(3) EX_USAGE
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf 'CFLAGS=%s\n' "$CFLAGS" >cc.mk
|
||||||
|
printf 'RUSTFLAGS=%s\n' "$RUSTFLAGS" >rustc.mk
|
|
@ -9,18 +9,19 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if ! ls GNUmakefile >/dev/null 2>&1
|
if ! ls Makefile >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
printf '%s: Run this script in the root of the project.\n' "$0" 1>&2
|
printf '%s: Run this script in the root of the project.\n' "$0" 1>&2
|
||||||
exit 64 # sysexits.h(3) EX_USAGE
|
exit 64 # sysexits.h(3) EX_USAGE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
make clean
|
make clean
|
||||||
|
./configure clean
|
||||||
|
./configure
|
||||||
|
|
||||||
for CC in cc \
|
for CC in cc \
|
||||||
clang \
|
clang \
|
||||||
gcc \
|
gcc \
|
||||||
tcc \
|
|
||||||
'zig cc'
|
'zig cc'
|
||||||
do
|
do
|
||||||
export CC
|
export CC
|
||||||
|
|
Loading…
Reference in New Issue
Block a user