Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing default calling convention of c++ sources makes linking fail #1068

Open
madebr opened this issue Apr 13, 2023 · 1 comment
Open
Labels
bug C++ C++ compiler

Comments

@madebr
Copy link

madebr commented Apr 13, 2023

When compiling a c++ source with -ecc, linking fails because main_ cannot be found.

In the CMake script below, the a_c executable links succesfully, but a_cxx does not.
Because linking fails, this blocks me from adding -ecc to CMAKE_CXX_FLAGS in CMake toolchain files.

Consider the following cmake script:

set(CMAKE_SYSTEM_NAME "DOS")
set(CMAKE_SYSTEM_PROCESSOR "x86")

set(CMAKE_C_COMPILER "wcl386")
set(CMAKE_CXX_COMPILER "wcl386")

cmake_minimum_required(VERSION 3.20)
project(test C CXX)

file(WRITE a.c [[
int main(int argc, char *argv[]) {
  return 0;
}
]])

file(WRITE a.cpp [[
int main(int argc, char *argv[]) {
  return 0;
}
]])

add_executable(a_c a.c)
target_compile_options(a_c PRIVATE "-ecc")

add_executable(a_cpp a.cpp)
target_compile_options(a_cpp PRIVATE "-ecc")

Complete build log:

$ ninja -j1 -v
[1/4] /home/maarten/owatcom2/binl/wcl386 -zq -d+  -I/home/maarten/owatcom2/h -w3 -bt=dos -d2 -ecc -foCMakeFiles/a_c.dir/a.c.obj -c -cc /tmp/ww/a.c
/tmp/ww/a.c(1): Warning! W303: Parameter 'argv' has been defined, but not referenced
/tmp/ww/a.c(1): Warning! W303: Parameter 'argc' has been defined, but not referenced
[2/4] : && /home/maarten/owatcom2/binl/wlink option quiet name a_c.exe opt map system dos4g debug all file {CMakeFiles/a_c.dir/a.c.obj}   && :
[3/4] /home/maarten/owatcom2/binl/wcl386 -zq -d+  -I/home/maarten/owatcom2/h -w3 -bt=dos -xs -d2 -ecc -foCMakeFiles/a_cpp.dir/a.cpp.obj -c -cc++ /tmp/ww/a.cpp
[4/4] : && /home/maarten/owatcom2/binl/wlink option quiet name a_cpp.exe opt map system dos4g debug all file {CMakeFiles/a_cpp.dir/a.cpp.obj}   && :
FAILED: a_cpp.exe 
: && /home/maarten/owatcom2/binl/wlink option quiet name a_cpp.exe opt map system dos4g debug all file {CMakeFiles/a_cpp.dir/a.cpp.obj}   && :
Error! E2028: main_ is an undefined reference
file clib3r.lib(cmain386.c): undefined symbol main_
ninja: build stopped: subcommand failed.
@jmalak
Copy link
Member

jmalak commented Mar 4, 2024

see issue #1187 and #1246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C++ C++ compiler
Projects
None yet
Development

No branches or pull requests

2 participants