View previous topic :: View next topic |
Author |
Message |
DietmarSiepmann
Joined: 03 Jun 2013 Posts: 279
|
Posted: Wed Jul 15, 2020 9:46 am Post subject: Scc 64 bit: /debug error + erroneous warnings |
|
|
In many Fortran apps we make calls to C/C++ and hence make use of scc 64 bit.
Compiling the following C code for 64 bit (named wrong_warning.cpp) produces erroneous warnings and results in an error if specifiying scc option /debug:
Code: |
#include <stdio.h>
#include <string.h>
int main(int argc,char *argv[]) {
int j=0;
printf("argc=%d\n",argc);
if (argc > 1) {
printf("argv[1]=%s\n",argv[1]);
} else {
printf("No parameter specified ... exiting\n");
return 1;
}
if( strcmp(argv[1],"point") == 0 )
j=1;
else if(strcmp(argv[1],"polygon") == 0 )
j=2;
else
j=3;
printf("Case=%d\n",j);
return 0;
}
|
Command
Code: | scc wrong_warning.cpp /link /64 |
displays warnings
Code: | [Silverfrost SCC/WIN32 Ver 4.31 Copyright (c) Silverfrost Ltd 2
0009 printf("No parameter specified ... exiting\n");
WARNING - This statement will never be executed
0012 if( strcmp(argv[1],"point") == 0 )
WARNING - This statement will never be executed
0014 else if(strcmp(argv[1],"polygon") == 0 )
WARNING - This statement will never be executed
0017 j=3;
WARNING - This statement will never be executed
NO ERRORS, 4 WARNINGS [<WRONG_WARNING> SCC/WIN32 Ver 4.31]
[SLINK64 v2.14, Copyright (c) Silverfrost Ltd. 2015-2020]
Loading c:\ds\samples\salford_8.40\lgotemp@.OBJ
Creating executable file WRONG_WARNING.EXE |
which are not true. This may be shown via commands
Code: | wrong_warning.exe
wrong_warning.exe point
wrong_warning.exe point1
|
Moreover, adding option /debug to the scc command mentioned above in order to produce a 64 bit debuggable exe file results in an error and does not create an exe file:
Code: | c:\ds\samples\salford_8.40>scc wrong_warning.cpp /link /64 /debug
[Silverfrost SCC/WIN32 Ver 4.31 Copyright (c) Silverfrost Ltd 2020]
0020 }
*** Attempt to emit 32-bit instruction in /64 mode
1 ERRORS [<WRONG_WARNING> SCC/WIN32 Ver 4.31]
*** Compilation failed |
If omitting option /64 and thus creating the corresponding 32 bit versions these phenomenons do not occur.
Regards,
Dietmar |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Wed Jul 15, 2020 11:08 am Post subject: |
|
|
Dietmar
Thank you for the feedback. However, 64 bit SCC still has the status of being unsupported. These issues are known and will need to be fixed before changing the status of SCC. In the meantime it may be possible to fix some bugs if they are blocking a user's progress. |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Wed Jul 15, 2020 12:06 pm Post subject: |
|
|
Since Silverfrost use a proprietary format for 64-bit OBJ files and static libraries, users face an obstacle when they wish to use a C subroutine with their Fortran code and SCC-64 runs into a bug.
When I was in a similar situation, I used the Microsoft C compiler to produce a DLL instead of an OBJ or a static library, and linked the FTN95-compiled 64-bit code with that DLL. |
|
Back to top |
|
|
DietmarSiepmann
Joined: 03 Jun 2013 Posts: 279
|
Posted: Fri Jul 17, 2020 12:56 pm Post subject: |
|
|
mecej4,
many thanks for your hint. I've tried to make use of it and could generate a ftn95 source from which I called into a C/CPP Dll both being created with the debug flag set. The executable worked as expected, but unfortunately I was not able to debug into the function implemented in the dll via sdbg64.
Here is the code:
Ftn95 file sample1.for:
Code: |
C_EXTERNAL MYSUM 'MYSUM' (REF,REF):INTEGER*4
integer*4 j,s1,s2
s1=1
s2=2
#IF _WIN64
write(*,*) '64 Bit App'
#ENDIF
j=MYSUM(s1,s2)
write(*,*) 'j=MYSUM(s1,s2)=',j
END
|
C/CPP file sample1_dll.cpp:
Code: |
#include <windows.h>
#include <stdio.h>
extern "C" __declspec(dllexport) int MYSUM (int *a, int *b)
{
int c;
c=*a+*b;
printf("MYSUM contained in dll sample1_dll.dll\n");
return c ;
}
|
Commands to build
Code: |
ftn95 sample1.for /debug /CFPP /64
cl sample1_dll.cpp /LD /Zi
slink64 sample1.lnk
| where file sample1.lnk is given by
Code: |
lo sample1
lo sample1_dll.dll
file sample1.exe
|
and where cl is the 64 bit Microsoft C compiler. I may debug sample1.exe via command
and via F8 I may step up to function call MYSUM. Pressing F7 to step into the function does not work and steps over the function.
I thought maybe there would be a chance to step into it.
Version info:
Code: |
[FTN95/x64 Ver. 8.63.0 Copyright (c) Silverfrost Ltd 1993-2020]
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x64
|
Regards,
Dietmar |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Sun Dec 06, 2020 5:23 am Post subject: |
|
|
I am curious about what "C" compiler you are using for the 64-bit interfacing routines.
I understand SCC for 64-bit is unsupported, but you are using some "C" compiler from somewhere.
My 64-bit "C" code will not compile (compiler crashes).
Bill |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Sun Dec 06, 2020 8:21 am Post subject: |
|
|
Bill
Although 64 bit SCC is officially "unsupported", this just means that we currently do not guarantee to fix all reported bugs.
Please supply code that illustrates the compiler failure that you have encountered so that we can move towards a fully supported SCC. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Sun Dec 06, 2020 3:47 pm Post subject: |
|
|
I have the folder with the source, the error.txt file from the crash (all are similar; same instruction location, different target addresses), and the CMD file. I placed a lot (but not all) of the failing compile steps at the beginning of the command file.
Here's the DropBox link.
https://www.dropbox.com/t/bDu1QC4snBhnOwyu |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Mon Dec 07, 2020 8:37 am Post subject: |
|
|
Bill
Thanks. I will take a look. |
|
Back to top |
|
|
DietmarSiepmann
Joined: 03 Jun 2013 Posts: 279
|
Posted: Tue Dec 08, 2020 3:24 pm Post subject: |
|
|
Bill,
as far as I remember I used MSVC "C/C++" Comiler (cl) to build a dll from file sample1_dll.cpp (instead of an object built with SALFORD's scc). I wanted to verify mecej4`s hint to call into a dll instead of an object in order to be able to debug into the C code. But unfortunately I was not successful in doing so
We are are calling into C/C++ Code from a big 32 bit GUI app written in Fortran and we are porting this app to 64 bit using ftn95 and scc. There are some warnings and problems with "scc /64" but we could compile much of the C/C++ code successfully.
Regards,
Dietmar |
|
Back to top |
|
|
|