Skip to content

Commit 164eea5

Browse files
committed
Actually test linker script processing
The goto-cc personality does not invoke linker script processing, hence the tests located in the ansi-c folder were a no-op. Moving them to the goto-gcc folder showed that they wouldn't work as is, which is also fixed now: 1) Add -static so as not to generate dynamic linking headers, which those linker scripts leave no room for. 2) Actually detect failure of linker script parsing by enabling warnings and testing for them. 3) Make sure ls_parse.py is available on the PATH. 4) Linker scripts aren't supported by Apple's linker.
1 parent 087296a commit 164eea5

File tree

12 files changed

+48
-14
lines changed

12 files changed

+48
-14
lines changed

regression/goto-gcc/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
2+
set(not_gnu_ld -X gnu-ld-only)
3+
else()
4+
set(not_gnu_ld "")
5+
endif()
6+
17
# TARGET_FILE (as used in other directories) can't be used with goto-gcc as it
28
# isn't marked as an executable (target), which CMake requires. Thus construct a
39
# path in the same way the symbolic link is created in the goto-cc directory.
4-
add_test_pl_tests("$<TARGET_FILE_DIR:goto-cc>/goto-gcc")
10+
add_test_pl_tests("$<TARGET_FILE_DIR:goto-cc>/goto-gcc" ${not_gnu_ld})
511

612
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/archives/libour_archive.a"
713
COMMAND "$<TARGET_FILE_DIR:goto-cc>/goto-gcc" -c foo.c
@@ -15,3 +21,11 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/archives/libour_archive.a
1521
add_custom_target(libour_archive.a ALL
1622
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/archives/libour_archive.a"
1723
)
24+
25+
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
26+
set_property(
27+
TEST "goto-gcc-CORE"
28+
PROPERTY ENVIRONMENT
29+
"PATH=$ENV{PATH}:$<TARGET_FILE_DIR:goto-cc>"
30+
)
31+
endif()

regression/goto-gcc/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ test:
99
tests.log: ../test.pl
1010

1111
else
12+
ifeq ($(BUILD_ENV_),OSX)
13+
not_gnu_ld = -X gnu-ld-only
14+
endif
1215
test: ../../src/goto-cc/goto-gcc
13-
@../test.pl -e -p -c ../../../src/goto-cc/goto-gcc
16+
@PATH=../../../scripts:$$PATH \
17+
../test.pl -e -p -c ../../../src/goto-cc/goto-gcc $(not_gnu_ld)
1418

1519
tests.log: ../test.pl ../../src/goto-cc/goto-gcc
16-
@../test.pl -e -p -c ../../../src/goto-cc/goto-gcc
20+
@PATH=../../../scripts:$$PATH \
21+
../test.pl -e -p -c ../../../src/goto-cc/goto-gcc $(not_gnu_ld)
1722

1823
../../src/goto-cc/goto-gcc: ../../src/goto-cc/goto-cc
1924
@ln -sf goto-cc ../../src/goto-cc/goto-gcc

regression/ansi-c/linker_script_start+end/main.c renamed to regression/goto-gcc/linker_script_start+end/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ extern char src_start[];
22
extern char src_end[];
33
extern char dst_start[];
44

5-
void *memcpy(void *dest, void *src, unsigned n){
5+
void *memcpy(void *dest, void *src, unsigned n)
6+
{
67
return (void *)0;
78
}
89

9-
int main(){
10+
int main()
11+
{
1012
memcpy(dst_start, src_start, (unsigned)src_end - (unsigned)src_start);
1113
return 0;
1214
}

regression/ansi-c/linker_script_start+end/test.desc renamed to regression/goto-gcc/linker_script_start+end/test.desc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
CORE
1+
CORE gnu-ld-only
22
main.c
3-
-o out.gb -T script.ld -nostdlib
3+
-o out.gb -T script.ld -nostdlib -static -Wall
44
^EXIT=0$
55
^SIGNAL=0$
66
--
7+
Problem parsing linker script
78
^warning: ignoring
89
^CONVERSION ERROR$
910
--

regression/ansi-c/linker_script_start+size/main.c renamed to regression/goto-gcc/linker_script_start+size/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ extern char src_start[];
22
extern char src_size[];
33
extern char dst_start[];
44

5-
void *memcpy(void *dest, void *src, unsigned n){
5+
void *memcpy(void *dest, void *src, unsigned n)
6+
{
67
return (void *)0;
78
}
89

9-
int main(){
10+
int main()
11+
{
1012
memcpy(dst_start, src_start, (unsigned)src_size);
1113
return 0;
1214
}

regression/ansi-c/linker_script_start+size/test.desc renamed to regression/goto-gcc/linker_script_start+size/test.desc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
CORE
1+
CORE gnu-ld-only
22
main.c
3-
-o out.gb -T script.ld -nostdlib
3+
-o out.gb -T script.ld -nostdlib -static -Wall
44
^EXIT=0$
55
^SIGNAL=0$
66
--
7+
Problem parsing linker script
78
^warning: ignoring
89
^CONVERSION ERROR$
910
--
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
extern char sym[];
22

3-
int main(){
3+
int main()
4+
{
45
int foo = (int)sym;
56
return 0;
67
}

0 commit comments

Comments
 (0)