__VERSION__ in squeakvm classic

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

__VERSION__ in squeakvm classic

stes
 


In the subversion sources of "Squeakvm" classic

platforms/unix/vm/config.cmake

there is a line

SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
\"__VERSION__")



Now on Solaris 11.4 or 11.3 with SunPRO C compiler there is an issue with
__VERSION__

the following sample program:

bash-4.4$ cat x.c

#include <stdio.h>

int main(int argc,char *argv[])
{
  printf("%s\n",__DATE__);
  printf("%s\n",__TIME__);
  printf("%s\n",__VERSION__);
}


when compiled with GCC 9.2 on Solaris I get:

$ gcc x.c
$ ./a.out
Mar 29 2020
15:43:33
9.2.0

when compiling with SunPRO C 12.6 on Solaris the result is :

$ cc x.c
"x.c", line 8: undefined symbol: __VERSION__
cc: acomp failed for x.c


I could be using GCC 9.2 to build the squeakvm of course but because I tried
with the SunPRO C,
this only defines __DATE__ and __TIME__ but not __VERSION__ (as far as I
know).

So perhaps the best level to fix this (minor and only) issue with the
compile of the squeakvm with the SunPRO C would be at the

platforms/unix/vm/config.cmake

level




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: __VERSION__ in squeakvm classic

stes
 

There also exists a

CMAKE_<LANG>_COMPILER_VERSION

in cmake, maybe that could be used as cmake level alternative to __VERSION__
(at cc level)

this cmake feature does not work 100% correctly because it detects

-- The C compiler identification is SunPro 5.15.0

where the version 5.15.0 is incorrect, but it is probably set to
CMAKE_C_COMPILER_VERSION
so extracted from the string "Sun C 5.15"

bash-4.4$ svn diff platforms/
Index: platforms/unix/vm/config.cmake
===================================================================
--- platforms/unix/vm/config.cmake (revision 3775)
+++ platforms/unix/vm/config.cmake (working copy)
@@ -202,7 +202,7 @@
 
 # sqUnixMain.c
 
-SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
\"__VERSION__")
+SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
${CMAKE_C_COMPILER_VERSION}\"")
 
 CONFIG_DEFINE (VM_BUILD_STRING)


in any case, the squeakvm builds fine if I change the vm/config.cmake

./build/config.status:VM_BUILD_STRING="Unix built on "__DATE__ " "__TIME__"
Compiler: 5.15.0"

It results in my case in

bash-4.4$ strings squeakvm | grep Unix
Unix built on Mar 29 2020 16:46:30 Compiler: 5.15.0

However such a modification to vm/config.cmake would change VM_BUILD_STRING
for virtually all platforms/builds ...



--
Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: __VERSION__ in squeakvm classic

stes
 

Using CMAKE_C_COMPILER_VERSION is perhaps not a bad idea,

as alternative to __VERSION__

when I build the classic vm with gcc 9.2

it correctly identifies this as:

-- The C compiler identification is GNU 9.2.0

it results in a

./build/config.h:#define VM_BUILD_STRING "Unix built on "__DATE__ "
"__TIME__" Compiler: 9.2.0"


as far as I can see the classic vm is not compiling on Solaris with gcc 9.2

it fails on

./squeakvm/src/plugins/FT2Plugin/FT2Plugin.c:37:10: fatal error: ft2build.h:
No such file or directory
   37 | #include <ft2build.h>

but the test with GCC was just to see how it sets VM_BUILD_STRING on that
platform.




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: __VERSION__ in squeakvm classic

David T. Lewis
In reply to this post by stes
 
On Sun, Mar 29, 2020 at 08:49:29AM -0500, stes wrote:

>
> In the subversion sources of "Squeakvm" classic
>
> platforms/unix/vm/config.cmake
>
> there is a line
>
> SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
> \"__VERSION__")
>
>
>
> Now on Solaris 11.4 or 11.3 with SunPRO C compiler there is an issue with
> __VERSION__
>
> the following sample program:
>
> bash-4.4$ cat x.c
>
> #include <stdio.h>
>
> int main(int argc,char *argv[])
> {
>   printf("%s\n",__DATE__);
>   printf("%s\n",__TIME__);
>   printf("%s\n",__VERSION__);
> }
>
>
> when compiled with GCC 9.2 on Solaris I get:
>
> $ gcc x.c
> $ ./a.out
> Mar 29 2020
> 15:43:33
> 9.2.0
>
> when compiling with SunPRO C 12.6 on Solaris the result is :
>
> $ cc x.c
> "x.c", line 8: undefined symbol: __VERSION__
> cc: acomp failed for x.c
>
>
> I could be using GCC 9.2 to build the squeakvm of course but because I tried
> with the SunPRO C,
> this only defines __DATE__ and __TIME__ but not __VERSION__ (as far as I
> know).
>
> So perhaps the best level to fix this (minor and only) issue with the
> compile of the squeakvm with the SunPRO C would be at the
>
> platforms/unix/vm/config.cmake
>
> level
>

Yes, that sounds right to me.

Here is a web page that gives some reference information on predefined
macros for various compilers:

 http://beefchunk.com/documentation/lang/c/pre-defined-c/precomp.html

So maybe there is a way to use the __SUNPRO_C macro in config.cmake. I am
only guessing here, but possibly something like this will work:


IF (__SUNPRO_C)
  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler: \"__SUNPRO_C")
ELSE ()
  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler: \"__VERSION__")
ENDIF (__SUNPRO_C)


Dave

Reply | Threaded
Open this post in threaded view
|

Re: __VERSION__ in squeakvm classic

stes
 

There is a

IF (CMAKE_COMPILER_IS_GNUCC)

so I could use that

but the IF (__SUNPRO_C) doesn't seem to work

in C source files  I use __SUNPRO_C like in

platforms/unix/vm/include_ucontext.h:#elif __SUNPRO_C && __i386__

but I don't think that the config.cmake is "preprocessed" by cc -E.

The nicest solution seems CMAKE_<LANG>_COMPILER_VERSION
or possibly IF (CMAKE_COMPILER_IS_GNUCC)




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: __VERSION__ in squeakvm classic

David T. Lewis
 
On Sun, Mar 29, 2020 at 12:50:52PM -0500, stes wrote:

>  
>
> There is a
>
> IF (CMAKE_COMPILER_IS_GNUCC)
>
> so I could use that
>
> but the IF (__SUNPRO_C) doesn't seem to work
>
> in C source files  I use __SUNPRO_C like in
>
> platforms/unix/vm/include_ucontext.h:#elif __SUNPRO_C && __i386__
>
> but I don't think that the config.cmake is "preprocessed" by cc -E.
>
> The nicest solution seems CMAKE_<LANG>_COMPILER_VERSION
> or possibly IF (CMAKE_COMPILER_IS_GNUCC)
>
You are right, CMAKE_C_COMPILER_VERSION is the nicest solution.

I changed the line in platforms/unix/vm/config.cmake to this:

SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler: ${CMAKE_C_COMPILER_VERSION}\"")

This produces the correct output on Linux with gcc, so if it works
also on Solaris then I think it is the right fix.

I am attaching a copy of the full config.cmake file for reference.

Can you check and see if this works on Solaris?

Thanks,
Dave
 

config.cmake (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: __VERSION__ in squeakvm classic

stes
 

The line

SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
${CMAKE_C_COMPILER_VERSION}\"")

works for me on Solaris intel (amd64) with both SunPro C 5.15 and GCC 9.2.

It sets CMAKE_C_COMPILER_VERSION to 5.15:

results in:
./build64/config.h:#define VM_BUILD_STRING "Unix built on "__DATE__ "
"__TIME__" Compiler: 5.15.0"

and this compiles fine for me with Sun Pro while the code with __VERSION__
aborts the compile.

I am not familiar with "cmake" but I guess that this needs to be tested on
all compilers.

Not just gcc and SunPro C , but also clang, icc and whathever compiler can
be detected by "cmake".

It's more of a "cmake" issue, and perhaps I could ask for help on a cmake
forum,

There appear to be ways (interestingly) for testing different compilers in
"cmake" :

https://cmake.org/Bug/view.php?id=8530

for example with :

elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")

or

elseif(CMAKE_C_COMPILER_ID STREQUAL "SunPro")

etc.




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: __VERSION__ in squeakvm classic

stes
 

also the following C program:

bash-4.4$ cat x.c

#include <stdio.h>

int main(int argc,char *argv[])
{
  printf("%x\n",__SUNPRO_C);
}

produces


bash-4.4$ ./a.out
5150

This matches the description at
http://beefchunk.com/documentation/lang/c/pre-defined-c/precomp.html

__SUNPRO_C = 0xVRP V = Version R = Revision P = Patch

so basically the "cmake" variable CMAKE_C_COMPILER_VERSION in
+SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
${CMAKE_C_COMPILER_VERSION}\"")

correctly identifies the version as

(cd build64; ../../platforms/unix/cmake/configure --prefix=/u/src/squeak
--src=../../src --image64 --vm-only "--CFLAGS='-m64 -O2
-D_FILE_OFFSET_BITS=64'")
-- Configuring squeak 4.16.7-3775 for i386-pc-solaris2.11
-- Using source directory /u/src/squeakvm/src
-- The C compiler identification is SunPro 5.15.0


and it sets  CMAKE_C_COMPILER_VERSION to 5.15.0  (correct).




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: __VERSION__ in squeakvm classic

stes
 

A combination of "cmake" methods may also be used:

The following works for me as well:  in platforms/unix/vm/config.cmake

IF (CMAKE_C_COMPILER_ID MATCHES "SunPro")
  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
${CMAKE_C_COMPILER_VERSION}\"")
ELSE ()
  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
\"__VERSION__")
ENDIF (CMAKE_C_COMPILER_ID MATHCES "SunPro")

CONFIG_DEFINE (VM_BUILD_STRING)

This is a combination where for the "SunPro" compiler the variable
CMAKE_C_COMPILER_VERSION is used,
while for all other compilers the __VERSION__ is used.

The above method using CMAKE_C_COMPILER_VERSION  can be used for all C
compilers that do not define __VERSION__.

The above works fine for me,  and there is less of a risk that it breaks
something for other platforms.

So the patch is then:

bash-4.4$ svn diff platforms/
Index: platforms/unix/vm/config.cmake
===================================================================
--- platforms/unix/vm/config.cmake (revision 3775)
+++ platforms/unix/vm/config.cmake (working copy)
@@ -202,7 +202,11 @@
 
 # sqUnixMain.c
 
-SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\" Compiler:
\"__VERSION__")
+IF (CMAKE_C_COMPILER_ID MATCHES "SunPro")
+  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\"
Compiler: ${CMAKE_C_COMPILER_VERSION}\"")
+ELSE ()
+  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\"
Compiler: \"__VERSION__")
+ENDIF (CMAKE_C_COMPILER_ID MATHCES "SunPro")
 
 CONFIG_DEFINE (VM_BUILD_STRING)
 
Index: platforms/unix/vm-sound-Sun/sqUnixSoundSun.c
===================================================================
--- platforms/unix/vm-sound-Sun/sqUnixSoundSun.c (revision 3775)
+++ platforms/unix/vm-sound-Sun/sqUnixSoundSun.c (working copy)
@@ -72,7 +72,7 @@
 #endif
 
 static sqInt sound_Stop(void);
-static int sound_AvailableSpace(void);
+static sqInt sound_AvailableSpace(void);
 
 static int auFd=       -1;   /* open on /dev/audio */
 static int auCtlFd=       -1;   /* open on /dev/audioctl */




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html