Topic
  • No replies
mgphl52
mgphl52
4 Posts

Pinned topic AIX COBOL sub-program compile options

‏2013-05-07T18:18:55Z |

How can I get cob2 to not generate an entry point for ".main" when compiling a sub-program?

TIA!

-michael

  • outlaw
    outlaw
    41 Posts
    ACCEPTED ANSWER

    Re: AIX COBOL sub-program compile options

    ‏2013-05-10T20:02:41Z  
    • mgphl52
    • ‏2013-05-10T17:29:54Z

    We have a mixture of processing where most all batch compiles are done as DYNAM, but the CICS must be NODYNAM.

    Output from the link is reporting duplicates for the ".main" entry point in all of the archived subprograms. Is this normal?

    Yes, NODYNAM (the default) is required if EXEC CICS or EXEC SQL are used - however, dynamically bound calls are still supported via CALL <identifier>

    I, personally, do not recommend ever using DYNAM:

    1) It hurts performance (slightly to significantly) by turning what could've been a statically bound call to a dynamically bound call

    2) I prefer being explicit and use CALL <identifier> when I need to make a dynamically bound call

    I realize there are valid use cases for DYNAM, but it seems to be mostly used improperly - or, at least, sub-optimally

    If you separately compile a bunch of routines and plonk them in an archive to use with a static link, then yeah, duplicate "main" entry points are going to happen, and you have to be careful which one is listed first (it will be the one, true, main) on the link step.

    "main" is part of Posix and C standards, and every program that is compatible with C will have a main(), which is called by the C library _start() routine after the module is loaded and execution starts.  This, coupled with the COBOL definition of "main program" and "sub program" being related strictly to the outermost COBOL program is what causes this confusing message.

  • outlaw
    outlaw
    41 Posts

    Re: AIX COBOL sub-program compile options

    ‏2013-05-07T22:20:14Z  

    `man cob2', see the -cmain and -main options.

    A description of what you are attempting to accomplish might get you a more refined answer.

    If you are statically binding multiple, separate compilations, or say, using dynamic calls to access subroutines, will change how you need to compile/link

  • mgphl52
    mgphl52
    4 Posts

    Re: AIX COBOL sub-program compile options

    ‏2013-05-10T17:29:54Z  
    • outlaw
    • ‏2013-05-07T22:20:14Z

    `man cob2', see the -cmain and -main options.

    A description of what you are attempting to accomplish might get you a more refined answer.

    If you are statically binding multiple, separate compilations, or say, using dynamic calls to access subroutines, will change how you need to compile/link

    We have a mixture of processing where most all batch compiles are done as DYNAM, but the CICS must be NODYNAM.

    Output from the link is reporting duplicates for the ".main" entry point in all of the archived subprograms. Is this normal?

  • outlaw
    outlaw
    41 Posts

    Re: AIX COBOL sub-program compile options

    ‏2013-05-10T20:02:41Z  
    • mgphl52
    • ‏2013-05-10T17:29:54Z

    We have a mixture of processing where most all batch compiles are done as DYNAM, but the CICS must be NODYNAM.

    Output from the link is reporting duplicates for the ".main" entry point in all of the archived subprograms. Is this normal?

    Yes, NODYNAM (the default) is required if EXEC CICS or EXEC SQL are used - however, dynamically bound calls are still supported via CALL <identifier>

    I, personally, do not recommend ever using DYNAM:

    1) It hurts performance (slightly to significantly) by turning what could've been a statically bound call to a dynamically bound call

    2) I prefer being explicit and use CALL <identifier> when I need to make a dynamically bound call

    I realize there are valid use cases for DYNAM, but it seems to be mostly used improperly - or, at least, sub-optimally

    If you separately compile a bunch of routines and plonk them in an archive to use with a static link, then yeah, duplicate "main" entry points are going to happen, and you have to be careful which one is listed first (it will be the one, true, main) on the link step.

    "main" is part of Posix and C standards, and every program that is compatible with C will have a main(), which is called by the C library _start() routine after the module is loaded and execution starts.  This, coupled with the COBOL definition of "main program" and "sub program" being related strictly to the outermost COBOL program is what causes this confusing message.

  • mgphl52
    mgphl52
    4 Posts

    Re: AIX COBOL sub-program compile options

    ‏2013-05-13T12:04:48Z  
    • outlaw
    • ‏2013-05-10T20:02:41Z

    Yes, NODYNAM (the default) is required if EXEC CICS or EXEC SQL are used - however, dynamically bound calls are still supported via CALL <identifier>

    I, personally, do not recommend ever using DYNAM:

    1) It hurts performance (slightly to significantly) by turning what could've been a statically bound call to a dynamically bound call

    2) I prefer being explicit and use CALL <identifier> when I need to make a dynamically bound call

    I realize there are valid use cases for DYNAM, but it seems to be mostly used improperly - or, at least, sub-optimally

    If you separately compile a bunch of routines and plonk them in an archive to use with a static link, then yeah, duplicate "main" entry points are going to happen, and you have to be careful which one is listed first (it will be the one, true, main) on the link step.

    "main" is part of Posix and C standards, and every program that is compatible with C will have a main(), which is called by the C library _start() routine after the module is loaded and execution starts.  This, coupled with the COBOL definition of "main program" and "sub program" being related strictly to the outermost COBOL program is what causes this confusing message.

    Thank you, "outlaw"

    The real answer then is "no," just accept the run of duplicate ".main" entries in the link output listing.

    BTW, I have been campaigning for all statically linked except where dynamic is required for some time. Excessive run-times may help me with this argument..

  • outlaw
    outlaw
    41 Posts

    Re: AIX COBOL sub-program compile options

    ‏2013-05-14T20:48:38Z  
    • mgphl52
    • ‏2013-05-13T12:04:48Z

    Thank you, "outlaw"

    The real answer then is "no," just accept the run of duplicate ".main" entries in the link output listing.

    BTW, I have been campaigning for all statically linked except where dynamic is required for some time. Excessive run-times may help me with this argument..

    Note that you can, and you seem to already be, putting routines in an archive (shared library) and statically linking to that - which gives you the best of both worlds:
    1) Static linking to the shared library removes the dynamic call overhead

    2) The archive (shared library) can be chmod o+rx and cached by AIX (man genkld and slibclean), giving you much, if not all of the gains of dynamic linkage.