Skip to content

Commit a1b018c

Browse files
committed
Allow using non-gold linkers, fix some potential errors, and install libdispatch into /usr/GNUstep
1 parent 6b7613f commit a1b018c

6 files changed

+103
-16
lines changed

clang-build

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
CLANG=${1:-clang}
44
CLANGPP=${2:-clang++}
5+
linker=${3:-ld.gold}
56

67
echo "Using..."
78
echo ${CLANG}
89
echo ${CLANGPP}
10+
echo ${linker}
911
echo "--"
1012

11-
$(which bash) ./tools-scripts/compile-all "/usr/GNUstep" "${CLANG}" "${CLANGPP}"
13+
$(which bash) ./tools-scripts/compile-all "/usr/GNUstep" "${CLANG}" "${CLANGPP}" "${linker}"
1214
exit

clang-setup

+28-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/bin/sh
2+
# shellcheck disable=SC2016
23

34
CLANG=${1:-clang}
45
CLANGPP=${2:-clang++}
6+
linker=${3:-ld.gold}
7+
8+
LD=$(which "${linker}")
9+
export LDFLAGS="-fuse-ld=$LD"
510

611
SUDO='sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH'
712
CPUS="1"
8-
ARCH=`uname -m`
13+
ARCH=$(uname -m)
914

1015
cd /tmp
1116

@@ -21,15 +26,20 @@ ${SUDO} rm -rf /tmp/libobjc2
2126
git clone --recursive https://github.com/gnustep/libobjc2.git
2227

2328
# set vars
24-
export CC=${CLANG}
25-
export CXX=${CLANGPP}
29+
export CC="${CLANG}"
30+
export CXX="${CLANGPP}"
2631

2732
# build and install
2833
echo "======== Installing libobjc2..."
2934
cd /tmp/libobjc2
3035
mkdir build
3136
cd build
32-
cmake -DGNUSTEP_INSTALL_TYPE=LOCAL ../
37+
cmake -DGNUSTEP_INSTALL_TYPE=SYSTEM ../ \
38+
-DCMAKE_C_COMPILER="${CC}" \
39+
-DCMAKE_CXX_COMPILER="${CXX}" \
40+
-DCMAKE_ASM_COMPILER="${CC}" \
41+
-DCMAKE_LINKER="${LD}" \
42+
-DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}"
3343
make -j${CPUS}
3444
${SUDO} -E make install && ${SUDO} ldconfig
3545

@@ -41,7 +51,20 @@ cd /tmp/libdispatch
4151
rm -rf build
4252
mkdir build
4353
cd build
44-
cmake ../
54+
cmake ../ \
55+
-DCMAKE_C_COMPILER="${CC}" \
56+
-DCMAKE_CXX_COMPILER="${CXX}" \
57+
-DCMAKE_ASM_COMPILER="${CC}" \
58+
-DCMAKE_LINKER="${LD}" \
59+
-DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" \
60+
-DCMAKE_INSTALL_BINDIR="$(gnustep-config --variable=GNUSTEP_SYSTEM_TOOLS)" \
61+
-DCMAKE_INSTALL_LIBDIR="$(gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARIES)" \
62+
-DCMAKE_INSTALL_INCLUDEDIR="$(gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS)" \
63+
-DCMAKE_INSTALL_MANDIR="$(gnustep-config --variable=GNUSTEP_SYSTEM_DOC_MAN)" \
64+
-DCMAKE_INSTALL_INFODIR="$(gnustep-config --variable=GNUSTEP_SYSTEM_DOC_INFO)" \
65+
-DCMAKE_INSTALL_DOCDIR="$(gnustep-config --variable=GNUSTEP_SYSTEM_DOC)" \
66+
-DCMAKE_INSTALL_DATAROOTDIR="$(gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARY)" \
67+
-DTESTS=OFF
4568
make -j${CPUS}
4669
${SUDO} -E make install && ${SUDO} ldconfig
4770
fi

compile-all

+41-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ if [ "$3" != "" ]; then
3535
cxxcompiler="$3"
3636
fi
3737

38+
if [ "$4" != "" ]; then
39+
linker=$4
40+
fi
41+
42+
3843
# Check if we are compiling under windows...
3944
UNAME=`uname | cut -d'-' -f1`
4045
if [ "$UNAME" != "MINGW32_NT" ] ; then
@@ -75,9 +80,38 @@ else
7580
export CXX=$cxxcompiler
7681
fi
7782

83+
if [[ "$CC" == gcc* ]]; then
84+
USING_GCC=true
85+
else
86+
USING_GCC=false
87+
fi
88+
89+
if [ "$4" == "" ]; then
90+
if ! $USING_GCC; then
91+
linker=ld.gold
92+
fi
93+
else
94+
LD=$(which "$linker")
95+
if $USING_GCC; then
96+
# We must create a directory and symlink the linker into there.
97+
mkdir temp_linker_dir
98+
cd temp_linker_dir
99+
ln -s "$LD" ./ld
100+
cd ..
101+
export LDFLAGS="$LDFLAGS -B$(realpath temp_linker_dir)"
102+
else
103+
# Clang allows constructions such as -fuse-ld=/usr/bin/ld.lld-18
104+
export LDFLAGS="$LDFLAGS -fuse-ld=$LD"
105+
fi
106+
fi
78107
echo "==== compile-all"
79108
echo "Using compiler $CC"
80109
echo "Using c++ compiler $CXX"
110+
if [ "$4" == "" ]; then
111+
echo "Using default linker"
112+
else
113+
echo "Using linker $LD"
114+
fi
81115
echo "===="
82116

83117
# Flags for windows build.
@@ -86,15 +120,15 @@ if [ "$UNAME" == "MINGW32_NT" ] ; then
86120
fi
87121

88122
# If we are building with clang, then add this to cc_flags
89-
if [ "$CC" != "gcc" ] ; then
123+
if ! $USING_GCC; then
90124
export cc_flags="-fblocks -fobjc-nonfragile-abi ${cc_flags}"
91125
fi
92126

93127
# Install make
94128
echo "Installing GNUstep into ${prefix}"
95129
cd tools-make
96130
# make distclean
97-
if [ "$CC" == "gcc" ]; then
131+
if $USING_GCC; then
98132
echo "==== BUILDING WITH GCC"
99133
echo "Build command: CCFLAGS=$cc_flags CC=$CC ./configure --prefix=${prefix} --with-library-combo=gnu-gnu-gnu --with-layout=gnustep $make_flags"
100134

@@ -109,8 +143,9 @@ else
109143
export CC=${compiler}
110144
export CXX=${cxxcompiler}
111145
# export LDFLAGS=-ldispatch
112-
export LDFLAGS=-fuse-ld=gold -ldispatch
113-
echo "CCFLAGS=${cc_flags} CXX=${CXX} CC=${CC} ./configure --prefix=${prefix} --with-library-combo=ng-gnu-gnu --enable-objc-arc --enable-native-objc-exceptions --with-layout=gnustep ${make_flags}"
146+
export LDFLAGS="$LDFLAGS -ldispatch"
147+
echo "LDFLAGS=$LDFLAGS"
148+
echo "Build command: CCFLAGS=${cc_flags} CXX=${CXX} CC=${CC} ./configure --prefix=${prefix} --with-library-combo=ng-gnu-gnu --enable-objc-arc --enable-native-objc-exceptions --with-layout=gnustep ${make_flags}"
114149
CCFLAGS=${cc_flags} CXX=${CXX} CC=${CC} ./configure --prefix=${prefix} --with-library-combo=ng-gnu-gnu --enable-objc-arc --enable-native-objc-exceptions --with-layout=gnustep ${make_flags}
115150
fi
116151

@@ -125,7 +160,7 @@ fi
125160
. $prefix/System/Library/Makefiles/GNUstep.sh
126161

127162
# Setup clang specific libraries...
128-
if [ "$CC" != "gcc" ]; then
163+
if ! $USING_GCC; then
129164
${scriptsdir}/clang-setup "$CLANG" "$CLANGPP"
130165
fi
131166

@@ -134,7 +169,7 @@ echo "======== Installing Base..."
134169
cd ../libs-base
135170
make distclean
136171
. $prefix/System/Library/Makefiles/GNUstep.sh
137-
$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes
172+
$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes || exit 1
138173
if [ "true" == "$NEEDSROOT" ]; then
139174
${SUDO} -u root ./install.sh $prefix $MAKE
140175
else

install-gnustep-llvm18-debian

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
wget https://apt.llvm.org/llvm.sh
2+
chmod +x llvm.sh
3+
sudo ./llvm.sh 18
4+
sudo apt install clang-18 clangd-18 lld-18 lldb-18 liblldb-18
5+
6+
export KERNEL=`uname -s | sed "s/\-.*//g" | awk '{print(tolower($0))}'`
7+
echo "Begin setup for ${KERNEL}"
8+
9+
# export USER=`whoami`
10+
# curl -fsSL > ./setup-${KERNEL} https://raw.githubusercontent.com/gnustep/tools-scripts/master/setup-${KERNEL}
11+
# . ./setup-${KERNEL}
12+
# rm ./setup-${KERNEL}
13+
source ./tools-scripts/setup-${KERNEL}
14+
15+
# mkdir -p gnustep
16+
# cd gnustep
17+
# git clone https://github.com/gnustep/tools-scripts
18+
./tools-scripts/clone-essential-repos-https
19+
20+
./tools-scripts/install-dependencies-${KERNEL}
21+
22+
./tools-scripts/clang-build clang-18 clang++-18 ld.lld-18
23+
24+
./tools-scripts/post-install-${KERNEL}
25+
26+
echo "Done..."

post-install-linux

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
pwd
4-
cd apps-gorm
4+
cd apps-gorm || exit 1
55
make debug=yes
6-
su -c 'make GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes install'
6+
sudo -E make GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes install
77

setup-linux

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ else
1313
fi
1414

1515
if [ ! -e /etc/sudoers.d/${USER} ]; then
16-
echo "Add ${USER} to sudoers"
16+
echo "Adding ${USER} to sudoers..."
17+
echo "Please enter the root user's password."
1718
su -c 'echo "${USER} ALL=(ALL:ALL) ALL" > /etc/sudoers.d/${USER}'
1819
else
19-
echo "User is already a member of sudo users."
20+
echo "${USER} is already a member of sudo users."
2021
fi

0 commit comments

Comments
 (0)