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
2626 endif()
2727 elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
2828 set(TCC_NATIVE_TARGET "x86_64")
29+ set(TCC_ARCH_DIR "x86_64-linux-gnu")
2930 else()
3031 set(TCC_NATIVE_TARGET "i386")
32+ set(TCC_ARCH_DIR "i386-linux-gnu")
3133 endif()
3234 endif()
3335
@@ -44,9 +46,9 @@ else() · 10 unmodified lines
4446 endif()
4547
4648 if(NOT WIN32)
47− if(EXISTS /usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/crti.o)
48− set(CONFIG_LDDIR lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)
49− set(CONFIG_MULTIARCHDIR ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)
49+ if(EXISTS /usr/lib/${TCC_ARCH_DIR}/crti.o)
50+ set(CONFIG_LDDIR lib/${TCC_ARCH_DIR})
51+ set(CONFIG_MULTIARCHDIR ${TCC_ARCH_DIR})
5052 elseif(EXISTS /usr/lib64/crti.o)
5153 set(CONFIG_LDDIR lib64)
5254 endif()
@@ -164,7 +166,10 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt · 111 unmodified lines
164166 tcctok.h
165167 ${tcc_sources}
166168 )
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()
168173 add_executable(tcc tcc.c)
169174 target_link_libraries(tcc libtcc)
170175 if(NOT WIN32)
i386-gen.c+8−0
@@ -464,6 +464,10 @@ ST_FUNC void gfunc_call(int nb_args) · 463 unmodified lines
464464 args_size -= 4;
465465 }
466466 }
467+#ifndef TCC_TARGET_PE
468+ else if ((vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT)
469+ args_size -= 4;
470+#endif
467471 gcall_or_jmp(0);
468472
469473 if (args_size && func_call != FUNC_STDCALL)
@@ -549,6 +553,10 @@ ST_FUNC void gfunc_prolog(CType *func_type) · 79 unmodified lines
549553 /* pascal type call ? */
550554 if (func_call == FUNC_STDCALL)
551555 func_ret_sub = addr - 8;
556+#ifndef TCC_TARGET_PE
557+ else if (func_vc)
558+ func_ret_sub = 4;
559+#endif
552560
553561 #ifdef CONFIG_TCC_BCHECK
554562 /* leave some room for bound checking code */
tests/CMakeLists.txt+2−2
@@ -5,7 +5,7 @@ if(WIN32) · 4 unmodified lines
55 set(TCC_CFLAGS ${TCC_CFLAGS} -I${CMAKE_SOURCE_DIR}/win32/include)
66 else()
77 set(TCC_MATH_LDFLAGS -lm)
8− set(LIBTCC_LDFLAGS -ldl -lm)
8+ set(LIBTCC_LDFLAGS -ldl -lm -Wl,-rpath=${CMAKE_BINARY_DIR})
99 endif()
1010
1111 add_executable(abitest-cc abitest.c)
@@ -61,7 +61,7 @@ if(PYTHONINTERP_FOUND) · 49 unmodified lines
6161 add_test(test6 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST6})
6262 endif()
6363
64− if(NOT WIN32 AND NOT TCC_NATIVE_TARGET STREQUAL "x86_64")
64+ if(0)
6565 # Static output
6666 set(TEST7 test7${CMAKE_EXECUTABLE_SUFFIX})
6767 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