mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-12 12:48:59 +00:00
![Zibi Sarbinowski](/assets/img/avatar_default.png)
This patch enables libc++ build as shared library in all combinations of ASCII/EBCDIC and 32-bit/64-bit variants. In particular it introduces: # ASCII version of libc++ named as libc++_a.so # Script to rename DLL name inside the generated side deck # Various names for dataset members where DLL libraries and their side decks will reside # Add the following options: - LIBCXX_SHARED_OUTPUT_NAME - LIBCXX_ADDITIONAL_COMPILE_FLAGS - LIBCXX_ADDITIONAL_LIBRARIES - LIBCXXABI_ADDITIONAL_COMPILE_FLAGS - LIBCXXABI_ADDITIONAL_LIBRARIES **Background and rational of this patch** The linker on z/OS creates a list of exported symbols in a file called side deck. The list contains the symbol name as well as the name of the DLL which implements the symbol. The name of the DLL depends on what is specified in the -o command line option. If it points to a USS file, than the DLL name in the side deck will be the USS file name. If it points to a member of a dataset then the DLL name in the side deck is the member name. If CMake could deal with z/OS datasets we could use -o that points to a dataset member name, but this does not seem to work so we have to produce a USS file as the DLL and then copy the content of the produced side deck to a dataset as well as rename the USS file name in the side deck to a dataset member name that corresponds to that DLL. Reviewed By: muiez, SeanP, ldionne, #libc, #libc_abi Differential Revision: https://reviews.llvm.org/D118503
58 lines
1.2 KiB
Bash
Executable File
58 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Script to rename DLL name within side deck.
|
|
#
|
|
|
|
# Stops execution if a command or pipeline has an error.
|
|
set -e
|
|
|
|
sidedeck=$1
|
|
old_dll_name=$2
|
|
new_dll_name=$3
|
|
|
|
function error() {
|
|
printf "ERROR: %s\n" "$*"
|
|
exit 1
|
|
}
|
|
|
|
function usage() {
|
|
cat <<EOF
|
|
Usage: $(basename $0) <side deck file> <old dll name> <new dll name>:
|
|
[-h|--help] Display this help and exit.
|
|
EOF
|
|
}
|
|
|
|
rename_dll_name_inside_side_deck() {
|
|
|
|
if [[ -z "$sidedeck" || -z "$old_dll_name" || -z "$new_dll_name" ]]; then
|
|
usage
|
|
error "All 3 parameters must be specified."
|
|
fi
|
|
|
|
[[ -f "$sidedeck" ]] || error "The '$sidedeck' file must exists."
|
|
|
|
old_len=${#old_dll_name}
|
|
new_len=${#new_dll_name}
|
|
|
|
if (( $new_len > $old_len )); then
|
|
error "New DLL name $new_dll_name must have $old_len characters or less."
|
|
fi
|
|
|
|
if ((padding_len=$old_len-$new_len )); then
|
|
pad=$(printf "%*s" $padding_len "")
|
|
fi
|
|
|
|
# Touch the temp. file and set the tag to 1047 first so the redirecting statement
|
|
# will write in 1047 and not 819 encoding.
|
|
touch $sidedeck.tmp; chtag -tc1047 $sidedeck.tmp
|
|
sed "/ IMPORT /s/'$old_dll_name/$pad'$new_dll_name/g" $sidedeck > $sidedeck.tmp
|
|
mv $sidedeck.tmp $sidedeck
|
|
}
|
|
|
|
function main() {
|
|
rename_dll_name_inside_side_deck
|
|
}
|
|
|
|
main "$@"
|
|
|