hi Scott,
We are not able to reproduce what you're seeing (tried every release in service v2.4 back to v2.2). Could you try this sample source and if you still have an issue with this, please open a support case?
xlc a.c -qmetal -S
__asm(
"xxzWork WTO TEXT=*,ROUTCDE=(11),LINKAGE=,MF=L \n"
: "DS"(xxzWork)
);
__asm(
"xxxUtilsStaticWtp WTO TEXT=*,ROUTCDE=(11),LINKAGE=,MF=L \n" // Static list form WTO
: "DS"(xxxUtilsStaticWtp) // DS name to locate list form of WTO
);
__asm(
"xxyUtilsStaticSWto WTO TEXT=*,ROUTCDE=(2,10),DESC=(3),LINKAGE=,MF=L \n" // Static list form WTO
: "DS"(xxyUtilsStaticSWto) // DS name to locate list form of WTO
);
int main(void) {
return 55;
}
---
Generated assembly static DSECT portion:
EJECT 000000
@@STATICD@@ DSECT 000000
DS XL776 000000
ORG @@STATICD@@+8 000000
@1xxzWork DS XL256 000000
ORG @@STATICD@@+264 000000
@2xxxUtilsStaticWtp DS XL256 000000
ORG @@STATICD@@+520 000000
@3xxyUtilsStaticSWto DS XL256 000000
---
------------------------------
Linda Chui
Compilation Technology & Enterprise Products
IBM Canada
------------------------------
Original Message:
Sent: Thu August 12, 2021 02:25 PM
From: Scott Fagen
Subject: Is there a way to get the IBM XL C/C++ Compiler, Metal Option to _NOT_ make an __asm DS declaration at the global scope not be an EXTERNAL?
Hi Linda,
Thank you for looking at this. I think you ought to have another look at my second post. It points out that when I relieve the name collision in the first eight characters of the DS identifier:
a) the problem goes away
b) neither symbol has an external created for the truncated name
What I think you have is a bug in the compiler. While I do not know the particulars of the IBM XL C/C++ compiler, it would appear that somewhere in your symbol table code, you have some confused code that somewhere believes that these DS symbols will need an external, but when the $STATIC area is built, they are just laid out in storage without any externals being built.
Thanks,
Scott
------------------------------
Scott Fagen
ESM Roving Contributor
Original Message:
Sent: Wed August 11, 2021 02:32 PM
From: Linda Chui
Subject: Is there a way to get the IBM XL C/C++ Compiler, Metal Option to _NOT_ make an __asm DS declaration at the global scope not be an EXTERNAL?
hi Scott,
(posting for a colleague)
Unfortunately there is no way to get a DS defined variable to be static (internal linkage).
The DS constraint is used to define a C variable using asm syntax. This is the same as defining a regular C variable that is longer than 8 characters in global scope (and gets the same error), so it is an expected error from the compiler.
Hope this helps!
------------------------------
Linda Chui
Compilation Technology & Enterprise Products
IBM Canada
Original Message:
Sent: Tue August 10, 2021 09:42 PM
From: Scott Fagen
Subject: Is there a way to get the IBM XL C/C++ Compiler, Metal Option to _NOT_ make an __asm DS declaration at the global scope not be an EXTERNAL?
Ok, further investigation/playing around has lead me to believe that this might be a compiler bug. If I rename one of the DS variables from xxxUtils... to xxyUtils... everything compiles correctly. Removing the "first eight character collision" eliminates the problem (which is how I will solve it for now).
There is nothing in the assembler listing that even references xxxUtils or xxyUtils, which leads me to believe that the symbols are being somehow incorrectly tagged while the compiler is building up the information to create the $STATIC area of the module:
...

... rest of $STATIC area
The xxxUtils list form WTO is at x'1D70' and the xxyUtils list form is at x'1E70'.
A search of the assembler listing for xxxUtils or xxyUtils yields nothing.
I'd expect that this is a bug of some sort...compiler gurus, what say you?
Thanks,
Scott
------------------------------
Scott Fagen
ESM Roving Contributor
Original Message:
Sent: Tue August 10, 2021 06:33 PM
From: Scott Fagen
Subject: Is there a way to get the IBM XL C/C++ Compiler, Metal Option to _NOT_ make an __asm DS declaration at the global scope not be an EXTERNAL?
-- Just acknowledging that my title incorrectly contains a double negative -- I'd like the variable to be scoped to the CSECT and not have an EXTERNAL generated. --
I am creating several similar (but not the same) invocations of the list form of the WTO macro in the global scope of my program:
__asm(
"xxxUtilsStaticWtp WTO TEXT=*,ROUTCDE=(11),LINKAGE=,MF=L \n" // Static list form WTO
: "DS"(xxxUtilsStaticWtp) // DS name to locate list form of WTO
);
...
__asm(
"xxxUtilsStaticSWto WTO TEXT=*,ROUTCDE=(2,10),DESC=(3),LINKAGE=,MF=L \n" // Static list form WTO
: "DS"(xxxUtilsStaticSWto) // DS name to locate list form of WTO
);
(Yes, I know that one has the label inside the assembler statement declaration and one does not, it does not appear to matter either way).
When this gets compiled, the compiler emits this information about these variables:
xxxUtilsStaticSWto Class = static, Length = 256
Type = struct __ASM_DS_256
3180-10:741, 3211-10:770
xxxUtilsStaticWtp Class = static, Length = 256
Type = struct __ASM_DS_256
3089-10:650, 3136-10:695
Plus this error message:
ERROR CCN3244 XXXXX.XXXXX.H(XXXUTILS):741 External variable XXXUTILS cannot be redefined.
(Note that it works fine if one of the declarations is removed).
If I understand this correctly, the compiler is shortening the name down to eight characters (I am not using GOFF) so both of these are colliding with name XXXUTILS.
I know that I can keep other kinds of declarations at the global scope from being EXTERNAL by adding "static" to the declaration, e.g.
static int MyRoutine(int Input) { <code> }
or
static int AnInt = 5;
I spent some quality time with Inline assembly statements (IBM extension), but could not divine how to somehow squeeze the word "static" into the __asm statement or if there was another way to do it.
Anybody have any ideas on how to accomplish this?
Thank you,
Scott Fagen
------------------------------
Scott Fagen
ESM Roving Contributor
------------------------------