Clang on X86: the linker does not pick up the rint function

Post Reply

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

Clang on X86: the linker does not pick up the rint function

Post by joukj » Thu Jun 15, 2023 2:58 am

I found the following:

Code: Select all

rumba-jj) cxx/vers
clang version 10.0.1 (git@bitbucket.org:vms_software/llvm-10.0.1.git d8f3c28f08a
5050f342e6fa1369a380ee6fb6359)
Build date: 04-13-2023
Target: x86_64-OpenVMS
Thread model: posix
InstalledDir: RUMBA$DKA100:[SYS0.SYSCOMMON.][SYSEXE]
rumba-jj) ty test.cxx
#include <math.h>
int main()
{
   int red;
   double cosine = 0.75;
     
   red = rint( ( cosine + 1 ) * 127.5 );

}
  15-JUN-2023 08:55:59
rumba-jj) cxx test
rumba-jj) link test
%ILINK-W-NUDFSYMS, 1 undefined symbol:
%ILINK-I-UDFSYM, 	rint 
%ILINK-W-USEUNDEF, undefined symbol rint referenced
	section: .text
	offset: %X0000000000000057
	module: TEST 
	file: $DISK0:[JOUKJ.test]TEST.OBJ;77 

If you use the C-compiler it just works fine.


hb
Valued Contributor
Posts: 79
Joined: Mon May 01, 2023 12:11 pm
Reputation: 0
Status: Offline

Re: Clang on X86: the linker does not pick up the rint function

Post by hb » Thu Jun 15, 2023 5:38 am

On IA64 the C++ compiler creates the symbol MATH$RINT_T for the rint function. That symbol is resolved from SYS$SHARE:DPML$SHR.EXE. On x86 the C++ compiler does not create the MATH$ symbol. So "rint" is in the object module rather than "MATH$RINT_T" (as one can see with ANALYZE/OBJECT/SECTION=SYMTAB).

Obviously the linker can't find the symbol "rint" in one of the default libraries or shareable images.

To me this looks like a problem in the C++ compiler.


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

Re: Clang on X86: the linker does not pick up the rint function

Post by jreagan » Thu Jun 15, 2023 9:50 pm

Yes, a bug in the C++ compiler. We'll have a newer kit next week that should resolve that missing MATH$ prefix


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

Re: Clang on X86: the linker does not pick up the rint function

Post by joukj » Mon Jun 19, 2023 7:02 am

But it did not work for the CXX I downloaded today.


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

Re: Clang on X86: the linker does not pick up the rint function

Post by jreagan » Mon Jun 19, 2023 10:40 am

I'll have the team double check


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

Re: Clang on X86: the linker does not pick up the rint function

Post by joukj » Tue Jul 25, 2023 5:14 am

The CXX compiler released yesterday does not even compile my reproducer.....

Code: Select all

 rumba-jj) cxx/vers 
clang version 10.0.1 (git@bitbucket.org:vms_software/llvm-10.0.1.git 1a6bcdeb1db
d320d5898ab7723bb691325ce8bd5)
Build date: 07-18-2023
Target: x86_64-OpenVMS
Thread model: posix
InstalledDir: RUMBA$DKA100:[SYS0.SYSCOMMON.][SYSEXE]
rumba-jj) ty test.cxx
#include <math.h>
int main()
{
   int red;
   double cosine = 0.75;
     
   red = rint( ( cosine + 1 ) * 127.5 );

}
rumba-jj) cxx test.cxx
In file included from $DISK0:[JOUKJ.test.bugs.cxx.rint]test.cxx;29:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/math.h:317:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/type_traits
:423:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/cstddef:43:
/CXX$SYSTEM_INCLUDE/version:1:1: error: expected unqualified-id
0.15.1b
^
In file included from $DISK0:[JOUKJ.test.bugs.cxx.rint]test.cxx;29:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/math.h:317:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/type_traits
:423:
/SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/cstddef:55:9: error: no member na
med 'ptrdiff_t' in the global namespace
using ::ptrdiff_t;
      ~~^
In file included from $DISK0:[JOUKJ.test.bugs.cxx.rint]test.cxx;29:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/math.h:317:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/type_traits
:424:
/CXX$SYSTEM_INCLUDE/version:1:1: error: expected unqualified-id
0.15.1b
^
In file included from $DISK0:[JOUKJ.test.bugs.cxx.rint]test.cxx;29:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/math.h:318:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/limits:127:
/CXX$SYSTEM_INCLUDE/version:1:1: error: expected unqualified-id
0.15.1b
^
4 errors generated.

User avatar

martinv
Master
Posts: 104
Joined: Fri Jun 14, 2019 11:05 pm
Reputation: 0
Location: Goslar, Germany
Status: Offline
Contact:

Re: Clang on X86: the linker does not pick up the rint function

Post by martinv » Tue Jul 25, 2023 6:48 am

Hmmm... it compiles cleanly on my system.

Code: Select all

$ cxx /version
clang version 10.0.1 (git@bitbucket.org:vms_software/llvm-10.0.1.git 1a6bcdeb1dbd320d5898ab7723bb691325ce8bd5)
Build date: 07-18-2023
Target: x86_64-OpenVMS
Thread model: posix
InstalledDir: X86VMS$DKA0:[SYS0.SYSCOMMON.][SYSEXE]
$ type test.cxx
#include <math.h>
int main()
{
        int red;
        double cosine = 0.75;

        red = rint( ( cosine + 1 ) * 127.5 );
}
$ cxx test.cxx
$ link test.obj
$ run test.exe
$ tcpip show version

  VSI TCP/IP Services for OpenVMS x86_64 Version 66.0
  on a VMware, Inc. VMware7,1 running OpenVMS V9.2-1

$
There is something wrong with everything that is popular.
(Charles Fort)


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

Re: Clang on X86: the linker does not pick up the rint function

Post by joukj » Tue Jul 25, 2023 7:45 am

I do run On KVM:

rumba-jj) tcpip sh vers

VSI TCP/IP Services for OpenVMS x86_64 Version 66.0
on a QEMU Standard PC (Q35 + ICH9, 2009) running OpenVMS V9.2-1


I tried to uninstall CXX first and than do a fresh install, but it fails (It does not pass IVP on my system)
I returned to the compiler of last month.
Last edited by joukj on Tue Jul 25, 2023 8:08 am, edited 1 time in total.


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

Re: Clang on X86: the linker does not pick up the rint function

Post by joukj » Thu Jul 27, 2023 2:27 am

Ok I figured out what went wrong:
I have the logical CXX$SYSTEM_INCLUDE redefined. In that case math.h cannot be found by the C++ compiler.

What do I have to add in this search string to make CXX find i.e. the <math.h>?


I can also confirm that the reproducer now runs fine and thet the rint function is found.
Last edited by joukj on Thu Jul 27, 2023 2:29 am, edited 1 time in total.

User avatar

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

Re: Clang on X86: the linker does not pick up the rint function

Post by arne_v » Thu Jul 27, 2023 6:50 pm

joukj wrote:
Thu Jul 27, 2023 2:27 am
Ok I figured out what went wrong:
I have the logical CXX$SYSTEM_INCLUDE redefined. In that case math.h cannot be found by the C++ compiler.

What do I have to add in this search string to make CXX find i.e. the <math.h>?
I have a math.h in:

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

that path look a bit weird, but if the directory get included then I assume the compiler will find math.h.
Arne
arne@vajhoej.dk
VMS user since 1986

Post Reply