History

Fixed i386 calling convention issue and CMake build on i386.

The i386 calling convention expects the callee to pop 1 word of the stack when performing a struct ret.

James Lyon committed 13 years ago

Commit ae2ece91 parent 1caee8a3 files · +19 −6Browse files

Unified · Split

3 files
  1. CMakeLists.txt +9 −4
  2. i386-gen.c +8 −0
  3. tests/CMakeLists.txt +2 −2
CMakeLists.txt+9−4
@@ -26,8 +26,10 @@ else() · 25 unmodified lines
26 endif()26 endif()
27 elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)27 elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
28 set(TCC_NATIVE_TARGET "x86_64")28 set(TCC_NATIVE_TARGET "x86_64")
29 set(TCC_ARCH_DIR "x86_64-linux-gnu")
29 else()30 else()
30 set(TCC_NATIVE_TARGET "i386")31 set(TCC_NATIVE_TARGET "i386")
32 set(TCC_ARCH_DIR "i386-linux-gnu")
31 endif()33 endif()
32endif()34endif()
33 35
@@ -44,9 +46,9 @@ else() · 10 unmodified lines
44endif()46endif()
45 47
46if(NOT WIN32)48if(NOT WIN32)
47 if(EXISTS /usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/crti.o)49 if(EXISTS /usr/lib/${TCC_ARCH_DIR}/crti.o)
48 set(CONFIG_LDDIR lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)50 set(CONFIG_LDDIR lib/${TCC_ARCH_DIR})
49 set(CONFIG_MULTIARCHDIR ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)51 set(CONFIG_MULTIARCHDIR ${TCC_ARCH_DIR})
50 elseif(EXISTS /usr/lib64/crti.o)52 elseif(EXISTS /usr/lib64/crti.o)
51 set(CONFIG_LDDIR lib64)53 set(CONFIG_LDDIR lib64)
52 endif()54 endif()
@@ -164,7 +166,10 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt · 111 unmodified lines
164 tcctok.h166 tcctok.h
165 ${tcc_sources}167 ${tcc_sources}
166 )168 )
167 set_target_properties(libtcc PROPERTIES OUTPUT_NAME tcc PREFIX lib LINK_FLAGS "-Wl,--output-def,libtcc.def")169 set_target_properties(libtcc PROPERTIES OUTPUT_NAME tcc PREFIX lib)
170 if(WIN32)
171 set_target_properties(libtcc PROPERTIES LINK_FLAGS "-Wl,--output-def,libtcc.def")
172 endif()
168 add_executable(tcc tcc.c)173 add_executable(tcc tcc.c)
169 target_link_libraries(tcc libtcc)174 target_link_libraries(tcc libtcc)
170 if(NOT WIN32)175 if(NOT WIN32)
i386-gen.c+8−0
@@ -464,6 +464,10 @@ ST_FUNC void gfunc_call(int nb_args) · 463 unmodified lines
464 args_size -= 4;464 args_size -= 4;
465 }465 }
466 }466 }
467#ifndef TCC_TARGET_PE
468 else if ((vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT)
469 args_size -= 4;
470#endif
467 gcall_or_jmp(0);471 gcall_or_jmp(0);
468 472
469 if (args_size && func_call != FUNC_STDCALL)473 if (args_size && func_call != FUNC_STDCALL)
@@ -549,6 +553,10 @@ ST_FUNC void gfunc_prolog(CType *func_type) · 79 unmodified lines
549 /* pascal type call ? */553 /* pascal type call ? */
550 if (func_call == FUNC_STDCALL)554 if (func_call == FUNC_STDCALL)
551 func_ret_sub = addr - 8;555 func_ret_sub = addr - 8;
556#ifndef TCC_TARGET_PE
557 else if (func_vc)
558 func_ret_sub = 4;
559#endif
552 560
553#ifdef CONFIG_TCC_BCHECK561#ifdef CONFIG_TCC_BCHECK
554 /* leave some room for bound checking code */562 /* leave some room for bound checking code */
tests/CMakeLists.txt+2−2
@@ -5,7 +5,7 @@ if(WIN32) · 4 unmodified lines
5 set(TCC_CFLAGS ${TCC_CFLAGS} -I${CMAKE_SOURCE_DIR}/win32/include)5 set(TCC_CFLAGS ${TCC_CFLAGS} -I${CMAKE_SOURCE_DIR}/win32/include)
6else()6else()
7 set(TCC_MATH_LDFLAGS -lm)7 set(TCC_MATH_LDFLAGS -lm)
8 set(LIBTCC_LDFLAGS -ldl -lm)8 set(LIBTCC_LDFLAGS -ldl -lm -Wl,-rpath=${CMAKE_BINARY_DIR})
9endif()9endif()
10 10
11add_executable(abitest-cc abitest.c)11add_executable(abitest-cc abitest.c)
@@ -61,7 +61,7 @@ if(PYTHONINTERP_FOUND) · 49 unmodified lines
61 add_test(test6 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST6})61 add_test(test6 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST6})
62 endif()62 endif()
63 63
64 if(NOT WIN32 AND NOT TCC_NATIVE_TARGET STREQUAL "x86_64")64 if(0)
65 # Static output65 # Static output
66 set(TEST7 test7${CMAKE_EXECUTABLE_SUFFIX})66 set(TEST7 test7${CMAKE_EXECUTABLE_SUFFIX})
67 add_custom_command(OUTPUT ${TEST7} COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -static -o ${TEST7} DEPENDS tcc tcctest.c)67 add_custom_command(OUTPUT ${TEST7} COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -static -o ${TEST7} DEPENDS tcc tcctest.c)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t