Skip to content

Commit

Permalink
ld: Document current "search" behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
tschwinge committed Nov 17, 2022
1 parent d93bdb4 commit 02a433c
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/GLOBAL_FUNCTION_DECL_f.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// BEGIN PREAMBLE
.version 3.1
.target sm_35
.address_size 64
// END PREAMBLE

// BEGIN GLOBAL FUNCTION DECL: f
.visible .func (.param.u32 %value_out) f (.param.u32 %in_ar0, .param.u32 %in_ar1);
15 changes: 15 additions & 0 deletions test/GLOBAL_FUNCTION_DEF_f.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// BEGIN PREAMBLE
.version 3.1
.target sm_35
.address_size 64
// END PREAMBLE

// BEGIN GLOBAL FUNCTION DECL: f
.visible .func (.param.u32 %value_out) f (.param.u32 %in_ar0, .param.u32 %in_ar1);

// BEGIN GLOBAL FUNCTION DEF: f
.visible .func (.param.u32 %value_out) f (.param.u32 %in_ar0, .param.u32 %in_ar1)
{
// [...]
ret;
}
86 changes: 86 additions & 0 deletions test/ld/search-1.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"Search" behavior.


RUN: rm -rf %t
RUN: mkdir -p %t
RUN: printf '\0' > %t/NUL


Assemble.

RUN: mkdir %t/o

RUN: %target_as_cmd -o %t/o/GLOBAL_FUNCTION_DECL_f.o %S/../GLOBAL_FUNCTION_DECL_f.s

RUN: %target_as_cmd -o %t/o/GLOBAL_FUNCTION_DEF_f.o %S/../GLOBAL_FUNCTION_DEF_f.s


Archive.

RUN: mkdir %t/a

RUN: %target_ar_cmd rcs %t/a/libGLOBAL_FUNCTION_f.a %t/o/GLOBAL_FUNCTION_DEF_f.o


Link manually.

RUN: cat %t/o/GLOBAL_FUNCTION_DECL_f.o %t/NUL %t/o/GLOBAL_FUNCTION_DEF_f.o %t/NUL > %t.nvptx.golden


Test.

RUN: rm -f %t.nvptx
RUN: %target_ld_cmd -o %t.nvptx %t/o/GLOBAL_FUNCTION_DECL_f.o %t/o/GLOBAL_FUNCTION_DEF_f.o > %t.stdout 2> %t.stderr
RUN: cmp %t.nvptx.golden %t.nvptx
RUN: ! test -s %t.stdout
RUN: ! test -s %t.stderr

TODO Not testing with linker input file '%t/a/libGLOBAL_FUNCTION_f.a', as we don't support that yet.

RUN: rm -f %t.nvptx
RUN: %target_ld_cmd -o %t.nvptx -L%t/o ./GLOBAL_FUNCTION_DECL_f.o ./GLOBAL_FUNCTION_DEF_f.o > %t.stdout 2> %t.stderr; r=$?; [ x"$r" = x1 ]
RUN: ! test -f %t.nvptx
RUN: ! test -s %t.stdout
RUN: echo 'error opening ./GLOBAL_FUNCTION_DECL_f.o' > %t.stderr.golden
RUN: cmp %t.stderr.golden %t.stderr

TODO The following one unexpectedly works:

RUN: rm -f %t.nvptx
RUN: %target_ld_cmd -o %t.nvptx -L%t/o GLOBAL_FUNCTION_DECL_f.o GLOBAL_FUNCTION_DEF_f.o > %t.stdout 2> %t.stderr
RUN: cmp %t.nvptx.golden %t.nvptx
RUN: ! test -s %t.stdout
RUN: ! test -s %t.stderr

RUN: rm -f %t.nvptx
RUN: ( cd %t/o/ && %target_ld_cmd -o %t.nvptx GLOBAL_FUNCTION_DECL_f.o GLOBAL_FUNCTION_DEF_f.o > %t.stdout 2> %t.stderr )
RUN: cmp %t.nvptx.golden %t.nvptx
RUN: ! test -s %t.stdout
RUN: ! test -s %t.stderr

RUN: rm -f %t.nvptx
RUN: %target_ld_cmd -o %t.nvptx %t/o/GLOBAL_FUNCTION_DECL_f.o -L%t/a -lGLOBAL_FUNCTION_f > %t.stdout 2> %t.stderr
RUN: cmp %t.nvptx.golden %t.nvptx
RUN: ! test -s %t.stdout
RUN: ! test -s %t.stderr

RUN: rm -f %t.nvptx
RUN: %target_ld_cmd -o %t.nvptx %t/o/GLOBAL_FUNCTION_DECL_f.o -lGLOBAL_FUNCTION_f > %t.stdout 2> %t.stderr; r=$?; [ x"$r" = x1 ]
RUN: ! test -f %t.nvptx
RUN: ! test -s %t.stdout
RUN: echo 'error opening libGLOBAL_FUNCTION_f.a' > %t.stderr.golden
RUN: cmp %t.stderr.golden %t.stderr

TODO The following one unexpectedly works:

RUN: rm -f %t.nvptx
RUN: ( cd %t/a/ && %target_ld_cmd -o %t.nvptx %t/o/GLOBAL_FUNCTION_DECL_f.o -lGLOBAL_FUNCTION_f > %t.stdout 2> %t.stderr )
RUN: cmp %t.nvptx.golden %t.nvptx
RUN: ! test -s %t.stdout
RUN: ! test -s %t.stderr

RUN: rm -f %t.nvptx
RUN: ( cd %t/a/ && %target_ld_cmd -o %t.nvptx %t/o/GLOBAL_FUNCTION_DECL_f.o -L. -lGLOBAL_FUNCTION_f > %t.stdout 2> %t.stderr )
RUN: cmp %t.nvptx.golden %t.nvptx
RUN: ! test -s %t.stdout
RUN: ! test -s %t.stderr

0 comments on commit 02a433c

Please sign in to comment.