x86-64 - header file permission problem with Clang

Post Reply

Topic author
dmccorm1
Contributor
Posts: 15
Joined: Fri Apr 14, 2023 4:33 pm
Reputation: 0
Status: Offline

x86-64 - header file permission problem with Clang

Post by dmccorm1 » Fri Apr 28, 2023 5:53 pm

There seems to be a defect in the C++ installer. I installed it when logged in as SYSTEM, which is the way I install everything. But when I try to compile anything when logged in in my normal account, I get issues such as the following:

Code: Select all

$ type hello.cpp
#include <cstdio>

int main()
{
    std::printf("Hello, World.\n");
    return 0;
}
$ clang hello.cpp
In file included from hello.cpp:1:
In file included from /sys$common/vsicxx$lib/include/lib_cxx/include/cstdio:104:
/sys$common/vsicxx$lib/include/lib_cxx/include/__config:1132:46: fatal error: cannot open file '/sys$common/vsicxx$lib/include/sys$starlet_c
/pthread.h': permission denied
      (defined(__MINGW32__) && __has_include(<pthread.h>))
                                             ^
1 error generated.
I can see that the installer has dropped all the header files under sys$common:[vsicxx$lib.include] as documented in the readme:

Code: Select all

$ dir sys$common:[vsicxx$lib.include]

Directory SYS$COMMON:[VSICXX$LIB.INCLUDE]

ARTIFICIAL.DIR;1    DECC$RTLDEF.DIR;1   lib_cxx.DIR;1       SYS$STARLET_C.DIR;1

Total of 4 files.
However, it seems that in the case of the starlet files that it has unpacked from the TLB, it hasn't set the permissions correctly:

Code: Select all

$ type sys$common:[vsicxx$lib.include.sys$starlet_c]pthread.h
%TYPE-W-OPENIN, error opening SYS$COMMON:[VSICXX$LIB.INCLUDE.SYS$STARLET_C]PTHREAD.H;1 as input
-RMS-E-PRV, insufficient privilege or file protection violation
$ set proc/priv=all
$ type sys$common:[vsicxx$lib.include.sys$starlet_c]pthread.h
/*
 *************************************************************************
 *                                                                       *
[SNIP]
I've done a SET SECURITY/PROT=(w:r) *.* in that directory and everything seems fine now. Not really being a VMS guy, I'm sure this wasn't the "correct" way to fix the issue but there you go.


sms
Master
Posts: 317
Joined: Fri Aug 21, 2020 5:18 pm
Reputation: 0
Status: Offline

Re: x86-64 - header file permission problem with Clang

Post by sms » Fri Apr 28, 2023 6:43 pm

Code: Select all

> However, it seems that in the case of the starlet files that it has
> unpacked from the TLB, it hasn't set the permissions correctly:

   Same here.  (I just threw a little C program at it, with the same
result.)

> I've done a SET SECURITY/PROT=(w:r) *.* in that directory and
> everything seems fine now. Not really being a VMS guy, I'm sure this
> wasn't the "correct" way to fix the issue but there you go.

   Well, the SYS$COMMON:[VSICXX$LIB.INCLUDE.lib_cxx.include] files are
(RWED,RWED,RE,RE), but I don't see what "E" actually buys you here.

   I do approximately nothing with C++, so I know nothing.  I might have
read something about this before I cared (even a little), but I see that
some sizes differ:

v87 $ cc siz.c
v87 $ link siz

v87 $ cxx siz.c /obj = siz_cxx
v87 $ link siz_cxx

v87 $ r siz
 char = 1, int = 4, long = 4, long long = 8, void* = 4.

v87 $ r siz_cxx
 char = 1, int = 4, long = 8, long long = 8, void* = 8.


pocketprobe
Valued Contributor
Posts: 51
Joined: Sat Apr 15, 2023 11:53 pm
Reputation: 0
Status: Offline

Re: x86-64 - header file permission problem with Clang

Post by pocketprobe » Fri Apr 28, 2023 7:06 pm

I'm glad to see I'm not the only one who had this issue doing C++

User avatar

arne_v
Master
Posts: 308
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: x86-64 - header file permission problem with Clang

Post by arne_v » Fri Apr 28, 2023 8:06 pm

Regarding the wrong permission.

I believe the C++ compiler is still formally in field test.

Field test is supposed to find the last remaining bugs before the general release.

Added in 4 minutes 52 seconds:
sms wrote:
Fri Apr 28, 2023 6:43 pm
I do approximately nothing with C++, so I know nothing. I might have
read something about this before I cared (even a little), but I see that
some sizes differ:

v87 $ cc siz.c
v87 $ link siz

v87 $ cxx siz.c /obj = siz_cxx
v87 $ link siz_cxx

v87 $ r siz
char = 1, int = 4, long = 4, long long = 8, void* = 4.

v87 $ r siz_cxx
char = 1, int = 4, long = 8, long long = 8, void* = 8.
That the C++ compiler default to 64 bit pointers and that long is 64 bit has been mentioned before.

I know you can use /POINTER=64 on Alpha and Itanium. Does /POINTER=32 work on x86-64?

The new size of long is probably going to be a problem for a lot of code - assumptions that long means 32 bit are probably widely spread in VMS code.

I believe that the right solution is to switch to int32_t and int64_t and get out of the mess with different sizes of those standard types.
Arne
arne@vajhoej.dk
VMS user since 1986


sms
Master
Posts: 317
Joined: Fri Aug 21, 2020 5:18 pm
Reputation: 0
Status: Offline

Re: x86-64 - header file permission problem with Clang

Post by sms » Fri Apr 28, 2023 11:23 pm

Code: Select all

> I believe that the right solution is to switch to int32_t and int64_t
> and get out of the mess with different sizes of those standard types.

   Sure, but...

   The original sin was not providing known-size types (along with the
char-short-int-long-... stuff), forcing people to choose between
defining their own (temporarily?) known-size types, or using what worked
until someone changed the environment.

   When doing the right thing is sufficiently more painful than doing a
wrong thing which works for now, I am not amazed when people avoid doing
the right thing.

User avatar

arne_v
Master
Posts: 308
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: x86-64 - header file permission problem with Clang

Post by arne_v » Sun Jun 25, 2023 2:36 pm

The sys$common:[vsicxx$lib.include.sys$starlet_c]*.h permission problem still exist with the latest VSI-X86VMS-CXX-A1000-230616-1.ZIP kit.
Arne
arne@vajhoej.dk
VMS user since 1986


jreagan
VSI Expert
Master
Posts: 135
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: x86-64 - header file permission problem with Clang

Post by jreagan » Mon Jun 26, 2023 9:48 am

I've let the development team know about the header permissions.

Yes, /POINTER=32 should work. Note that unlike Alpha/Itanium where there are two CXX RTLs (32-bit and 64-bit forms), we are providing just a 64-bit form (LLVM's libcxx).

And an upcoming C++ kit will provide support for reading headers from TLB files and the /LIBRARY qualifier on the command line. At that point, the installation won't have to extract the STARLET_C.TLB headers but can just read them directly from the TLB like the C compiler.


joukj
Master
Posts: 166
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Re: x86-64 - header file permission problem with Clang

Post by joukj » Wed Jul 19, 2023 5:35 am

arne_v wrote:
Fri Apr 28, 2023 8:11 pm

Added in 4 minutes 52 seconds:
sms wrote:
Fri Apr 28, 2023 6:43 pm
I do approximately nothing with C++, so I know nothing. I might have
read something about this before I cared (even a little), but I see that
some sizes differ:

v87 $ cc siz.c
v87 $ link siz

v87 $ cxx siz.c /obj = siz_cxx
v87 $ link siz_cxx

v87 $ r siz
char = 1, int = 4, long = 4, long long = 8, void* = 4.

v87 $ r siz_cxx
char = 1, int = 4, long = 8, long long = 8, void* = 8.
That the C++ compiler default to 64 bit pointers and that long is 64 bit has been mentioned before.

I know you can use /POINTER=64 on Alpha and Itanium. Does /POINTER=32 work on x86-64?

The new size of long is probably going to be a problem for a lot of code - assumptions that long means 32 bit are probably widely spread in VMS code.

I believe that the right solution is to switch to int32_t and int64_t and get out of the mess with different sizes of those standard types.

This size difference between the Cand C++ compilers on X86 gives me huge problems when C++ code calls C-libraries and vice versa. The C++ code includes the C-header fikles and interperts the types differently. Ofcourse you can change the code (but I have to make tons of changes).

It would be appreciated if the C and C++ compilers handle the types the same. (optinally by using a qualifier (i.e. /LONG_SIZE=8))

Jouk


jreagan
VSI Expert
Master
Posts: 135
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: x86-64 - header file permission problem with Clang

Post by jreagan » Wed Jul 19, 2023 9:28 am

"replacing long with int32_t" is exactly what we are doing in our own headers.

At the moment, there is no ability to change the size of long on any of the platforms or languages.

For C, long is 4 on Alpha/Itanium/x86.

For C++, long is 4 on Alpha/Itanium and 8 on x86
Last edited by jreagan on Wed Jul 19, 2023 9:29 am, edited 1 time in total.


joukj
Master
Posts: 166
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Re: x86-64 - header file permission problem with Clang

Post by joukj » Fri Jul 21, 2023 8:27 am

Foir me changing the header files of the C-libraries is not an option. Most of them are Opensource projects maintained elswhere. I do not think the maintainers like it to have tons of
#ifdef VMS
int32_t
#else
long
#endif

in their code. And I 'm not doing it locally every time a new version is released.



However the good news is that when the C-library is compiled with CXX it works with C++software. At the moment I have to have 2 versions of the library on my system, since C++ code is not working well with DecWindows (is that the same problem???)

regards
Jouk

Post Reply