Skip to content

Commit

Permalink
ld option
Browse files Browse the repository at this point in the history
  • Loading branch information
junjiemars committed May 4, 2024
1 parent 032e12c commit 2153ba2
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 6 deletions.
8 changes: 6 additions & 2 deletions auto/cc/clang
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ nm_trigraphs_opt="-Wno-trigraphs"
nm_openmp_opt="-fopenmp"

# lib
nm_libdir_opt="-L"
nm_lib_opt="-l"

nm_libdir_opt="-L"

# link option
LDFLAGS="${nm_libdir_opt}${NM_OUT}/lib${LDFLAGS:+ $LDFLAGS}"

# ld option
ld_entry_opt="-e"
ld_lib_opt="-l"
ld_libdir_opt="-L"
ld_out_opt="-o"

# eof
7 changes: 6 additions & 1 deletion auto/cc/gcc
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ nm_trigraphs_opt="-Wno-trigraphs"
nm_openmp_opt="-fopenmp"

# lib
nm_libdir_opt="-L"
nm_lib_opt="-l"
nm_libdir_opt="-L"

# link option
LDFLAGS="${nm_libdir_opt}${NM_OUT}/lib${LDFLAGS:+ $LDFLAGS}"

# ld option
ld_entry_opt="-e"
ld_lib_opt="-l"
ld_libdir_opt="-L"
ld_out_opt="-o"

# eof
5 changes: 5 additions & 0 deletions auto/cc/msvc
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,10 @@ nm_link_opt="-link"

LDFLAGS="${nm_link_opt} ${nm_libdir_opt}${NM_OUT}/lib${LDFLAGS:+ $LDFLAGS}"

# ld option
ld_entry_opt="-entry"
ld_lib_opt=
ld_libdir_opt="-libpath:"
ld_out_opt="-out"

# eof
6 changes: 6 additions & 0 deletions auto/make
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ nm_lib_opt = $nm_lib_opt
# link
nm_link_opt = $nm_link_opt
# ld
ld_entry_opt=$ld_entry_opt
ld_lib_opt=$ld_lib_opt
ld_libdir_opt=$ld_libdir_opt
ld_out_opt=$ld_out_opt
# path separator
nm_path_sep = $nm_path_sep
Expand Down
39 changes: 36 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ test_install_from_github () {
rm -r "${_CI_DIR_}"
fi
mkdir -p "$_CI_DIR_" && cd "$_CI_DIR_"

curl $b -sSfL | sh -s -- --branch=$_BRANCH_
}

Expand Down Expand Up @@ -291,6 +291,39 @@ test_nore_override_option () {
test_make clean test
}

test_nore_ld_option () {
local c="`basename $_CI_DIR_`.c"
local m="Makefile"

cat <<END > "$c"
#include <nore.h>
int main(void) {
return 0;
}
END

cat <<END > "$m"
include out/Makefile
ci_root := ./
ci_binout := \$(bin_path)/ci\$(bin_ext)
ci_objout := \$(tmp_path)/ci\$(obj_ext)
ci: \$(ci_binout)
ci_test: ci
\$(ci_binout)
\$(ci_binout): \$(ci_objout)
\$(LD) \$^ \$(ld_out_opt) \$@ \$(ld_lib_opt)c
\$(ci_objout): \$(ci_root)/ci.c
\$(CC) \$(CFLAGS) \$(INC) \$^ \$(nm_stage_c) \$(obj_out)\$@
END
test_what "CC=$CC ./configure #ld"
test_configure
test_make clean test
}

test_nore_auto_check () {
local a="auto"
sed -e 's/^#//g' "${_ROOT_DIR_}/auto/check" > "${a}"
Expand All @@ -303,7 +336,7 @@ if [ -n "$_INSIDE_CI_" ]; then
test_install_from_github
fi
env_ci_build
# test_make_print_database
test_make_print_database
test_nore_where_command
test_nore_new_option
test_nore_symbol_option
Expand All @@ -312,7 +345,7 @@ test_nore_std_option
test_nore_prefix_option
test_nore_override_option
test_nore_auto_check

test_nore_ld_option

# clean CI directory
[ -d "${_CI_DIR_}" ] && rm -r "${_CI_DIR_}"
Expand Down

0 comments on commit 2153ba2

Please sign in to comment.