1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2025-10-30 23:47:50 -04:00

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

View file

@ -22,7 +22,7 @@ jobs:
- name: autogen - name: autogen
run: ./autogen.sh run: ./autogen.sh
- name: configure - 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 - name: make
run: make run: make
- name: check - name: check
@ -51,7 +51,7 @@ jobs:
- name: autogen - name: autogen
run: ./autogen.sh run: ./autogen.sh
- name: configure - name: configure
run: ./configure --enable-tests --without-all CFLAGS='-fPIC' run: ./configure --enable-tests --without-all
- name: make - name: make
run: make run: make
- name: check - name: check

View file

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

View file

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

View file

@ -18,7 +18,7 @@ jobs:
- name: autogen - name: autogen
run: ./autogen.sh run: ./autogen.sh
- name: configure - name: configure
run: ./configure CFLAGS='-O3 -fPIC' run: ./configure CFLAGS='-O3'
- name: make - name: make
run: make run: make
- name: install - 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> 2022-02-01 Alex Kotov <kotovalexarian@gmail.com>
* configure.ac: Generate headers conditionally depending on options * configure.ac: Generate headers conditionally depending on options

View file

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

View file

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

View file

@ -14,6 +14,6 @@ export AR="$CROSS-ar"
export CC="$CROSS-gcc" export CC="$CROSS-gcc"
export RANLIB="$CROSS-ranlib" 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 CC="$CROSS-gcc"
export RANLIB="$CROSS-ranlib" 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 CC="$CROSS-gcc"
export RANLIB="$CROSS-ranlib" 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" PREFIX="$REPO/dest/dev-native"
export CFLAGS='-fPIC'
"$REPO/configure" --prefix="$PREFIX" --enable-tests "$REPO/configure" --prefix="$PREFIX" --enable-tests

View file

@ -14,6 +14,6 @@ export AR="$TARGET-ar"
export CC="$TARGET-gcc" export CC="$TARGET-gcc"
export RANLIB="$TARGET-ranlib" 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 CC="$TARGET-gcc"
export RANLIB="$TARGET-ranlib" 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 CC="$TARGET-gcc"
export RANLIB="$TARGET-ranlib" 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")")/..")" REPO="$(realpath "$(dirname "$(realpath "$0")")/..")"
if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi
export CFLAGS='-fPIC'
"$REPO/configure" --enable-tests "$REPO/configure" --enable-tests

View file

@ -16,6 +16,7 @@ AC_CANONICAL_HOST
dnl Features (enabled by default) dnl Features (enabled by default)
AC_ARG_ENABLE([bloat], AS_HELP_STRING([--disable-bloat], [disable unnecessary heavy binary data])) 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([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) dnl Features (disabled by default)
AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [enable tests and examples])) 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) dnl Features (enabled by default)
AM_CONDITIONAL([ENABLE_BLOAT], [test "$enable_bloat" != no]) AM_CONDITIONAL([ENABLE_BLOAT], [test "$enable_bloat" != no])
AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" != no]) AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" != no])
AM_CONDITIONAL([ENABLE_PIC], [test "$enable_pic" != no])
dnl Features (disabled by default) dnl Features (disabled by default)
AM_CONDITIONAL([ENABLE_TESTS], [test "$enable_tests" = yes]) 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) 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_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_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) dnl Features (disabled by default)
AS_IF([test "$enable_tests" = yes], [AC_DEFINE([ENABLE_TESTS], [1], [enabled tests and examples])]) 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]) AM_INIT_AUTOMAKE([1.9 subdir-objects])
AC_CONFIG_FILES([ AC_CONFIG_FILES([