Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

gcc-4.8: add library paths reported by system linker #691

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gcc-4.8/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source:
# along with using ${GCC_PREFIX}/.. fixes the issues with our configuration.
build:
detect_binary_files_with_prefix: false
number: 6
number: 7

requirements:
build:
Expand Down
9 changes: 8 additions & 1 deletion gcc-4.8/post-link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ else
c_runtime_obj_files_found=0

# Try locating crtXXX.o in default library search paths
for library_path in $(ld --verbose | grep SEARCH_DIR | sed -r 's/SEARCH_DIR\("=?([^"]*)"\);/ \1/g'); do
for library_path in $(/usr/bin/ld --verbose | grep SEARCH_DIR | sed -r 's/SEARCH_DIR\("=?([^"]*)"\);/ \1/g'); do
for obj_file in $C_RUNTIME_OBJ_FILES; do
obj_file_full_path="$library_path/$obj_file"
if [[ -e "$obj_file_full_path" ]]; then
Expand Down Expand Up @@ -111,6 +111,13 @@ else
# ... yada yada ... -isystem ${INCDIR}
sed -i ':a;N;$!ba;s|\(*cpp:\n[^\n]*\)|\1 -isystem '${INCDIR}'|g' "${SPECS_FILE}"
done

#
# Linux Portability Issue #2.5: linker also needs to find the rest of libc (i.e. libc.so in addition to crtXXX.o)
#
for library_path in $(/usr/bin/ld --verbose | grep SEARCH_DIR | sed -r 's/SEARCH_DIR\("=?([^"]*)"\);/ \1/g'); do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the full path to the system /usr/bin/ld instead of ld is a good idea. (It avoids problems if the user has a custom install of binutils.) While you're at it, can you also fix the call to ld on line 49, above?

sed -i ':a;N;$!ba;s|\(*link_libgcc:\n[^\n]*\)|\1 -L'${library_path}'|g' "${SPECS_FILE}"
done
fi

## TEST: Here we verify that gcc can build a simple "Hello world" program for both C and C++.
Expand Down