Main: generate position-independent code by default

Disable with "--disable-pic"
This commit is contained in:
Alex Kotov 2022-02-02 07:26:35 +05:00
parent a063bd4069
commit 44cb155baf
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
17 changed files with 46 additions and 36 deletions

View File

@ -10,7 +10,7 @@ main_freebsd_task:
- pkg install --yes autoconf automake
main_build_script:
- ./autogen.sh
- ./configure --enable-tests CFLAGS='-O3 -fPIC'
- ./configure --enable-tests CFLAGS='-O3'
- make
- sudo make install
main_test_script:
@ -25,7 +25,7 @@ mruby_freebsd_task:
- unzip mruby-3.0.0.zip
main_build_script:
- ./autogen.sh
- ./configure CFLAGS='-O3 -fPIC'
- ./configure CFLAGS='-O3'
- make
- sudo make install
mruby_test_script:
@ -45,7 +45,7 @@ ruby_freebsd_task:
- sudo make install
main_build_script:
- ./autogen.sh
- ./configure CFLAGS='-O3 -fPIC'
- ./configure CFLAGS='-O3'
- make
- sudo make install
ruby_build_script:
@ -67,7 +67,7 @@ rust_freebsd_task:
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
main_build_script:
- ./autogen.sh
- ./configure CFLAGS='-O3 -fPIC'
- ./configure CFLAGS='-O3'
- make
- sudo make install
rust_test_script:

View File

@ -22,7 +22,7 @@ jobs:
- name: autogen
run: ./autogen.sh
- name: configure
run: ./configure --enable-tests CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}} -fPIC'
run: ./configure --enable-tests CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}'
- name: make
run: make
- name: check
@ -51,7 +51,7 @@ jobs:
- name: autogen
run: ./autogen.sh
- name: configure
run: ./configure --enable-tests --without-all CFLAGS='-fPIC'
run: ./configure --enable-tests --without-all
- name: make
run: make
- name: check

View File

@ -18,7 +18,7 @@ jobs:
- name: autogen
run: ./autogen.sh
- name: configure
run: ./configure CFLAGS='-O3 -fPIC'
run: ./configure CFLAGS='-O3'
- name: make
run: make
- name: install

View File

@ -19,7 +19,7 @@ jobs:
- name: autogen
run: ./autogen.sh
- name: configure
run: ./configure CFLAGS='-O3 -fPIC'
run: ./configure CFLAGS='-O3'
- name: make
run: make
- name: install
@ -51,7 +51,7 @@ jobs:
- name: autogen
run: ./autogen.sh
- name: configure
run: ./configure --without-all CFLAGS='-O3 -fPIC'
run: ./configure --without-all CFLAGS='-O3'
- name: make
run: make
- name: install

View File

@ -18,7 +18,7 @@ jobs:
- name: autogen
run: ./autogen.sh
- name: configure
run: ./configure CFLAGS='-O3 -fPIC'
run: ./configure CFLAGS='-O3'
- name: make
run: make
- name: install

View File

@ -1,3 +1,8 @@
2022-02-02 Alex Kotov <kotovalexarian@gmail.com>
* configure.ac: Generate position-independent code by default, disable with
"--disable-pic"
2022-02-01 Alex Kotov <kotovalexarian@gmail.com>
* configure.ac: Generate headers conditionally depending on options

View File

@ -17,14 +17,6 @@ libkernaux_a_SOURCES = \
src/assert.c \
src/libc.c
if ENABLE_TESTS
TESTS = \
examples/assert_guards \
examples/assert_simple \
examples/panic_guards \
examples/panic_simple
endif
if ASM_I386
libkernaux_a_SOURCES += src/asm/i386.S
endif
@ -37,6 +29,14 @@ if ASM_X86_64
libkernaux_a_SOURCES += src/asm/x86_64.S
endif
if ENABLE_TESTS
TESTS = \
examples/assert_guards \
examples/assert_simple \
examples/panic_guards \
examples/panic_simple
endif
if WITH_CMDLINE
libkernaux_a_SOURCES += src/cmdline.c
if ENABLE_TESTS

View File

@ -103,6 +103,7 @@ stable options.
* `--enable-bloat`, disable with `--disable-bloat`
* `--enable-float`, disable with `--disable-float`
* `--enable-pic`, disable with `--disable-pic`
#### Packages
@ -121,7 +122,7 @@ Tips
```
./autogen.sh
./configure CFLAGS='-fPIC'
./configure
make
sudo make install
```
@ -133,7 +134,7 @@ environment.
```
./autogen.sh
./configure --enable-tests CFLAGS='-fPIC'
./configure --enable-tests
make
```
@ -150,6 +151,7 @@ without it in `$PATH`:
```
./configure \
--host='i386-elf' \
--disable-pic \
--with-libc \
AR="$(which i386-elf-ar)" \
CC="$(which i386-elf-gcc)" \

View File

@ -14,6 +14,6 @@ export AR="$CROSS-ar"
export CC="$CROSS-gcc"
export RANLIB="$CROSS-ranlib"
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -fno-pic'
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector'
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --disable-pic --with-libc

View File

@ -14,6 +14,6 @@ export AR="$CROSS-ar"
export CC="$CROSS-gcc"
export RANLIB="$CROSS-ranlib"
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -fno-pic'
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector'
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --disable-pic --with-libc

View File

@ -14,6 +14,6 @@ export AR="$CROSS-ar"
export CC="$CROSS-gcc"
export RANLIB="$CROSS-ranlib"
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -fno-pic -mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone'
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone'
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --disable-pic --with-libc

View File

@ -7,6 +7,4 @@ if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi
PREFIX="$REPO/dest/dev-native"
export CFLAGS='-fPIC'
"$REPO/configure" --prefix="$PREFIX" --enable-tests

View File

@ -14,6 +14,6 @@ export AR="$TARGET-ar"
export CC="$TARGET-gcc"
export RANLIB="$TARGET-ranlib"
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -fno-pic'
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector'
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --disable-pic --with-libc

View File

@ -14,6 +14,6 @@ export AR="$TARGET-ar"
export CC="$TARGET-gcc"
export RANLIB="$TARGET-ranlib"
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -fno-pic'
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector'
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --disable-pic --with-libc

View File

@ -14,6 +14,6 @@ export AR="$TARGET-ar"
export CC="$TARGET-gcc"
export RANLIB="$TARGET-ranlib"
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -fno-pic -mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone'
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone'
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc
"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --disable-pic --with-libc

View File

@ -5,6 +5,4 @@ set -e
REPO="$(realpath "$(dirname "$(realpath "$0")")/..")"
if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi
export CFLAGS='-fPIC'
"$REPO/configure" --enable-tests

View File

@ -16,6 +16,7 @@ AC_CANONICAL_HOST
dnl Features (enabled by default)
AC_ARG_ENABLE([bloat], AS_HELP_STRING([--disable-bloat], [disable unnecessary heavy binary data]))
AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable floating-point arithmeric]))
AC_ARG_ENABLE([pic], AS_HELP_STRING([--disable-pic], [do not generate position-independent code]))
dnl Features (disabled by default)
AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [enable tests and examples]))
@ -89,6 +90,7 @@ AM_CONDITIONAL([ASM_X86_64], [test "$host_cpu" = x86_64])
dnl Features (enabled by default)
AM_CONDITIONAL([ENABLE_BLOAT], [test "$enable_bloat" != no])
AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" != no])
AM_CONDITIONAL([ENABLE_PIC], [test "$enable_pic" != no])
dnl Features (disabled by default)
AM_CONDITIONAL([ENABLE_TESTS], [test "$enable_tests" = yes])
@ -124,6 +126,7 @@ AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86_64], [1]
dnl Features (enabled by default)
AS_IF([test "$enable_bloat" != no], [AC_DEFINE([ENABLE_BLOAT], [1], [enabled unnecessary heavy binary data])])
AS_IF([test "$enable_float" != no], [AC_DEFINE([ENABLE_FLOAT], [1], [enabled floating-point arithmeric])])
AS_IF([test "$enable_pic" != no], [AC_DEFINE([ENABLE_PIC], [1], [generate position-independent code])])
dnl Features (disabled by default)
AS_IF([test "$enable_tests" = yes], [AC_DEFINE([ENABLE_TESTS], [1], [enabled tests and examples])])
@ -179,6 +182,10 @@ AS_IF([test "$with_libc_strnlen" != yes], [AC_SUBST([comment_line_libc_strnlen],
AS_IF([test "$enable_pic" != no], [CFLAGS+=' -fpic '], [CFLAGS+=' -fno-pic'])
AM_INIT_AUTOMAKE([1.9 subdir-objects])
AC_CONFIG_FILES([