Skip to content

Commit

Permalink
Makefile, *.mk, ido, ish: remove IAMROOT_LIB_ variables
Browse files Browse the repository at this point in the history
This reverts partially commit a5672fd.
  • Loading branch information
gportay committed May 2, 2024
1 parent 7243309 commit f3ac21d
Show file tree
Hide file tree
Showing 9 changed files with 354 additions and 463 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Set the environment variable `IAMROOT_ORIGIN` using `DT_RUNPATH` if set in
`ld-iamroot.so(8)`

### Deprecated

- Replace the environment variables `IAMROOT_LIB` by the environment variable
`IAMROOT_ORIGIN`

### Fixed

- Fix the segmentation fault if the iamroot library is preloaded more than once
Expand Down
45 changes: 0 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,6 @@ PREFIX ?= /usr/local
COVERAGE ?= 0
OS ?= $(shell uname -o 2>/dev/null || uname -s 2>/dev/null)

IAMROOT_LIB ?= $(CURDIR)/libiamroot.so
export IAMROOT_LIB

IAMROOT_LIB_I686_LINUX_2 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_I686_LINUX_2

IAMROOT_LIB_X86_64_LINUX_X86_64_2 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_X86_64_LINUX_X86_64_2

IAMROOT_LIB_ARM_LINUX_3 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_ARM_LINUX_3

IAMROOT_LIB_ARMHF_LINUX_ARMHF_3 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_ARMHF_LINUX_ARMHF_3

IAMROOT_LIB_AARCH64_LINUX_AARCH64_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_AARCH64_LINUX_AARCH64_1

IAMROOT_LIB_RISCV64_LINUX_RISCV64_LP64D_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_RISCV64_LINUX_RISCV64_LP64D_1

IAMROOT_LIB_I686_MUSL_I386_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_I686_MUSL_I386_1

IAMROOT_LIB_X86_64_MUSL_X86_64_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_X86_64_MUSL_X86_64_1

IAMROOT_LIB_ARM_MUSL_ARM_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_ARM_MUSL_ARM_1

IAMROOT_LIB_ARMHF_MUSL_ARMHF_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_ARMHF_MUSL_ARMHF_1

IAMROOT_LIB_AARCH64_MUSL_AARCH64_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_AARCH64_MUSL_AARCH64_1

IAMROOT_LIB_RISCV64_MUSL_RISCV64_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_RISCV64_MUSL_RISCV64_1

IAMROOT_LIB_X86_64_ELF_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_X86_64_ELF_1

IAMROOT_LIB_AARCH64_ELF_1 ?= $(IAMROOT_LIB)
export IAMROOT_LIB_AARCH64_ELF_1

IAMROOT_EXEC ?= $(CURDIR)/exec.sh
export IAMROOT_EXEC

Expand Down
5 changes: 1 addition & 4 deletions ido
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ clear_and_preserve_env() {
done
}

IAMROOT_LIB="${IAMROOT_LIB:-/usr/local/lib/iamroot/libiamroot.so}"
export IAMROOT_LIB

IAMROOT_EXEC="${IAMROOT_EXEC:-/usr/local/lib/iamroot/exec.sh}"
export IAMROOT_EXEC

Expand Down Expand Up @@ -457,6 +454,6 @@ USER="${passwd[0]}" \
HOME="${HOME:-${passwd[5]}}" \
SHELL="${shell:-${passwd[6]}}" \
TERM="${TERM:-unknown}" \
LD_PRELOAD="$IAMROOT_LIB${LD_PRELOAD+:$LD_PRELOAD}" \
LD_PRELOAD="${IAMROOT_LIB:-${IAMROOT_ORIGIN:-/usr/local/lib/iamroot}/libiamroot.so}${LD_PRELOAD+:$LD_PRELOAD}" \
LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
"${command_timeout[@]}" "${command[@]}"
5 changes: 1 addition & 4 deletions ish
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ Environment variables:
EOF
}

IAMROOT_LIB="${IAMROOT_LIB:-/usr/local/lib/iamroot/libiamroot.so}"
export IAMROOT_LIB

IAMROOT_EXEC="${IAMROOT_EXEC:-/usr/local/lib/iamroot/exec.sh}"
export IAMROOT_EXEC

Expand Down Expand Up @@ -229,6 +226,6 @@ fi

ISHLVL="$((ISHLVL+1))" \
PATH="${PATH:-/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin}" \
LD_PRELOAD="$IAMROOT_LIB${LD_PRELOAD+:$LD_PRELOAD}" \
LD_PRELOAD="${IAMROOT_LIB:-${IAMROOT_ORIGIN:-/usr/local/lib/iamroot}/libiamroot.so}${LD_PRELOAD+:$LD_PRELOAD}" \
LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
exec "${SHELL:-/bin/sh}" "$@"
12 changes: 3 additions & 9 deletions support/freebsd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@
O ?= output
ARCH ?= $(shell uname -p 2>/dev/null)

IAMROOT_LIB ?= $(CURDIR)/$(ARCH)/libiamroot-elf.so.1
export IAMROOT_LIB

IAMROOT_LIB_X86_64_ELF_1 ?= $(CURDIR)/$(ARCH)/libiamroot-elf.so.1
export IAMROOT_LIB_X86_64_ELF_1

IAMROOT_LIB_AARCH64_ELF_1 ?= $(CURDIR)/$(ARCH)/libiamroot-elf.so.1
export IAMROOT_LIB_AARCH64_ELF_1

IAMROOT_PATH_RESOLUTION_IGNORE ?= ^/dev/|^/etc/resolv.conf
export IAMROOT_PATH_RESOLUTION_IGNORE

IAMROOT_EXEC ?= $(CURDIR)/exec.sh
export IAMROOT_EXEC

IAMROOT_ORIGIN ?= $(CURDIR)
export IAMROOT_ORIGIN

-include local.mk

.PHONY: all
Expand Down
58 changes: 3 additions & 55 deletions support/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export NVERBOSE
IAMROOT_EXEC ?= $(CURDIR)/exec.sh
export IAMROOT_EXEC

IAMROOT_ORIGIN ?= $(CURDIR)
export IAMROOT_ORIGIN

ifeq ($(ARCH),x86_64)
ifeq ($(LIBC),musl)
IAMROOT_LIB ?= $(IAMROOT_LIB_X86_64_MUSL_X86_64_1)
Expand All @@ -36,44 +39,6 @@ IAMROOT_LIB ?= $(IAMROOT_LIB_AARCH64_LINUX_AARCH64_1)
export IAMROOT_LIB
endif

#
# Stolen from buildroot (support/misc/utils.mk)
#
# SPDX-FileCopyrightText: The musl Contributors
#
# SPDX-License-Identifier: MIT
#
# Case conversion macros. This is inspired by the 'up' macro from gmsl
# (http://gmsl.sf.net). It is optimised very heavily because these macros
# are used a lot. It is about 5 times faster than forking a shell and tr.
#
# The caseconvert-helper creates a definition of the case conversion macro.
# After expansion by the outer $(eval ), the UPPERCASE macro is defined as:
# $(strip $(eval __tmp := $(1)) $(eval __tmp := $(subst a,A,$(__tmp))) ... )
# In other words, every letter is substituted one by one.
#
# The caseconvert-helper allows us to create this definition out of the
# [FROM] and [TO] lists, so we don't need to write down every substition
# manually. The uses of $ and $$ quoting are chosen in order to do as
# much expansion as possible up-front.
#
# Note that it would be possible to conceive a slightly more optimal
# implementation that avoids the use of __tmp, but that would be even
# more unreadable and is not worth the effort.

[FROM] := a b c d e f g h i j k l m n o p q r s t u v w x y z - .
[TO] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ _

define caseconvert-helper
$(1) = $$(strip \
$$(eval __tmp := $$(1))\
$(foreach c, $(2),\
$$(eval __tmp := $$(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),$$(__tmp))))\
$$(__tmp))
endef

$(eval $(call caseconvert-helper,UPPERCASE,$(join $(addsuffix :,$([FROM])),$([TO]))))

-include local.mk

MAKEFLAGS += --no-print-directory
Expand All @@ -84,7 +49,6 @@ all: libiamroot.so

.PHONY: vars
vars:
@echo export "IAMROOT_LIB=\"$(IAMROOT_LIB)\""
@echo export "IAMROOT_EXEC=\"$(IAMROOT_EXEC)\""
@echo export "IAMROOT_EXEC_IGNORE=\"$(IAMROOT_EXEC_IGNORE)\""

Expand All @@ -107,14 +71,6 @@ $(strip libiamroot.so \
endef

define libiamroot_so_abi =
iamroot_lib_$(1)_$(2) = $(1)/libiamroot.so.$(2)
IAMROOT_LIB_$(call UPPERCASE,$(1))_$(2) ?= $(CURDIR)/$(1)/libiamroot.so.$(2)
export IAMROOT_LIB_$(call UPPERCASE,$(1))_$(2)

vars: iamroot_lib_$(1)_$(2)
iamroot_lib_$(1)_$(2):
@echo export "IAMROOT_LIB_$(call UPPERCASE,$(1))_$(2)=\"$$(IAMROOT_LIB_$(call UPPERCASE,$(1))_$(2))\""

all: $(1)/libiamroot.so.$(2)

.PRECIOUS: $(1)/libiamroot.so.$(2)
Expand Down Expand Up @@ -146,14 +102,6 @@ clean-$(1).$(2):
endef

define libiamroot_ldso_so_abi =
iamroot_lib_$(1)_$(2)_$(3) = $(1)/libiamroot-$(2).so.$(3)
IAMROOT_LIB_$(call UPPERCASE,$(1)_$(2))_$(3) ?= $(CURDIR)/$(1)/libiamroot-$(2).so.$(3)
export IAMROOT_LIB_$(call UPPERCASE,$(1)_$(2))_$(3)

vars: iamroot_lib_$(1)_$(2)_$(3)
iamroot_lib_$(1)_$(2)_$(3):
@echo export "IAMROOT_LIB_$(call UPPERCASE,$(1)_$(2))_$(3)=\"$$(IAMROOT_LIB_$(call UPPERCASE,$(1)_$(2))_$(3))\""

all: $(1)/libiamroot-$(2).so.$(3)

.PRECIOUS: $(1)/libiamroot-$(2).so.$(3)
Expand Down
12 changes: 3 additions & 9 deletions support/netbsd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@ export PREFIX
O ?= output
ARCH ?= $(shell uname -p 2>/dev/null)

IAMROOT_LIB ?= $(CURDIR)/$(ARCH)/libiamroot.elf_so
export IAMROOT_LIB

IAMROOT_LIB_X86_64_ELF ?= $(CURDIR)/$(ARCH)/libiamroot.elf_so
export IAMROOT_LIB_X86_64_ELF

IAMROOT_LIB_AARCH64_ELF ?= $(CURDIR)/$(ARCH)/libiamroot.elf_so
export IAMROOT_LIB_AARCH64_ELF

IAMROOT_PATH_RESOLUTION_IGNORE ?= ^/dev/|^/proc/
export IAMROOT_PATH_RESOLUTION_IGNORE

IAMROOT_EXEC ?= $(CURDIR)/exec.sh
export IAMROOT_EXEC

IAMROOT_ORIGIN ?= $(CURDIR)
export IAMROOT_ORIGIN

-include local.mk

.PHONY: all
Expand Down
6 changes: 3 additions & 3 deletions support/openbsd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
O ?= output
ARCH ?= $(shell uname -p 2>/dev/null)

IAMROOT_LIB ?= $(CURDIR)/$(ARCH)/libiamroot.so
export IAMROOT_LIB

IAMROOT_PATH_RESOLUTION_IGNORE ?= ^/dev/|^/etc/resolv.conf
export IAMROOT_PATH_RESOLUTION_IGNORE

IAMROOT_EXEC ?= $(CURDIR)/exec.sh
export IAMROOT_EXEC

IAMROOT_ORIGIN ?= $(CURDIR)
export IAMROOT_ORIGIN

-include local.mk

.PHONY: all
Expand Down
Loading

0 comments on commit f3ac21d

Please sign in to comment.