forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Scc 64 bit: /debug error + erroneous warnings

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Wed Jul 15, 2020 9:46 am    Post subject: Scc 64 bit: /debug error + erroneous warnings Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed Jul 15, 2020 11:08 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Jul 15, 2020 12:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Fri Jul 17, 2020 12:56 pm    Post subject: Reply with quote

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
Code:
sdbg64 sample1.exe

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
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sun Dec 06, 2020 5:23 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sun Dec 06, 2020 8:21 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sun Dec 06, 2020 3:47 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Dec 07, 2020 8:37 am    Post subject: Reply with quote

Bill

Thanks. I will take a look.
Back to top
View user's profile Send private message AIM Address
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Tue Dec 08, 2020 3:24 pm    Post subject: Reply with quote

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 Sad

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group