Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error on Solaris 9 Sparc w/64 bit #1752

Closed
dago opened this issue Aug 9, 2017 · 8 comments
Closed

Build error on Solaris 9 Sparc w/64 bit #1752

dago opened this issue Aug 9, 2017 · 8 comments
Labels

Comments

@dago
Copy link
Contributor

dago commented Aug 9, 2017

The latest Curl 7.55.0 fails to build on Sparc V9 (64 bit) with

  CC       libcurl_la-warnless.lo
"warnless.c", line 117: #error: "SIZEOF_SIZE_T not defined"
cc: acomp failed for warnless.c
gmake[2]: *** [Makefile:1752: libcurl_la-warnless.lo] Error 1
gmake[2]: Leaving directory '/home/dam/mgar/pkg/curl/trunk/work/solaris10-sparc/build-isa-sparcv9-features-minimal/curl-7.55.0/lib'

I did this

The previous versions were building fine, this was just a rebuild.

I expected the following

I wonder why this wasn't caught by the autobuilds (on second thought, I vaguely remember I changed something in the builedbot configuration and got sidetracked before fixing some issues).

curl/libcurl version

7.55.0

[curl -V output]

Does not build yet.

operating system

Solaris 10 Sparc 64 bit with Sun Studio 12.

@dago
Copy link
Contributor Author

dago commented Aug 9, 2017

This seems to fix the issue:

diff --git a/lib/warnless.c b/lib/warnless.c
index fb085c8..7983513 100644
--- a/lib/warnless.c
+++ b/lib/warnless.c
@@ -107,7 +107,7 @@
 #elif (SIZEOF_SIZE_T == SIZEOF_INT)
 #  define CURL_MASK_SSIZE_T  CURL_MASK_SINT
 #  define CURL_MASK_USIZE_T  CURL_MASK_UINT
-#elif (SIZEOF_SIZE_T == CURL_SIZEOF_LONG)
+#elif (SIZEOF_SIZE_T == SIZEOF_LONG)
 #  define CURL_MASK_SSIZE_T  CURL_MASK_SLONG
 #  define CURL_MASK_USIZE_T  CURL_MASK_ULONG
 #elif (SIZEOF_SIZE_T == CURL_SIZEOF_CURL_OFF_T)

@bagder
Copy link
Member

bagder commented Aug 9, 2017

That's super strange to me. Can you understand why you need that change when CURL_SIZEOF_LONG is already used extensively in other places in that file and even before in the same file, like on line 72-86 ?

@bagder bagder added the build label Aug 9, 2017
@dago
Copy link
Contributor Author

dago commented Aug 11, 2017

Found the issue, these are the values after preprocessing:

"SIZEOF_SIZE_T"                  8
"SIZEOF_SHORT"                   2
"SIZEOF_INT"                     4
"CURL_SIZEOF_LONG"               4
"CURL_SIZEOF_CURL_OFF_T"         4
"SIZEOF_LONG"                    8

So in this code

#if (SIZEOF_SIZE_T == SIZEOF_SHORT)
#  define CURL_MASK_SSIZE_T  CURL_MASK_SSHORT
#  define CURL_MASK_USIZE_T  CURL_MASK_USHORT
#elif (SIZEOF_SIZE_T == SIZEOF_INT)
#  define CURL_MASK_SSIZE_T  CURL_MASK_SINT
#  define CURL_MASK_USIZE_T  CURL_MASK_UINT
#elif (SIZEOF_SIZE_T == CURL_SIZEOF_LONG)
#  define CURL_MASK_SSIZE_T  CURL_MASK_SLONG
#  define CURL_MASK_USIZE_T  CURL_MASK_ULONG
#elif (SIZEOF_SIZE_T == CURL_SIZEOF_CURL_OFF_T)
#  define CURL_MASK_SSIZE_T  CURL_MASK_SCOFFT
#  define CURL_MASK_USIZE_T  CURL_MASK_UCOFFT
#else
#  error "SIZEOF_SIZE_T not defined"
#endif

the error message is just misleading because it is defined but does not match any of the above cases.

Also I find it strange that CURL_SIZEOF_LONG != SIZEOF_LONG.

@bagder
Copy link
Member

bagder commented Aug 11, 2017

That's certainly the bug. The idea is that sparc 64bit should match system.h line 415-422, which should define both CURL_SIZEOF_LONG and CURL_SIZEOF_CURL_OFF_T to 8.

... but the define __sparc64__ seems to only be defined by gcc on sparc and I can find any generic defines for sparc + 64 on the predef site.

Do you know of any preprocessor directive to detect it running in 64 bit mode? __sparc seems to work to detect sparc at least.

@dago
Copy link
Contributor Author

dago commented Aug 11, 2017

We usually use this to differentiate between 32 and 64 bit on Solaris and it works on Sparc and x86, GCC and Sun/Oracle Studio:

#if defined __amd64 || defined __x86_64 || defined __sparcv9

See also here for specific definitions for the Oracle Studio compiler: https://docs.oracle.com/cd/E18752_01/html/816-5138/dev-env-2.html

@bagder
Copy link
Member

bagder commented Aug 11, 2017

For gcc I'm pretty sure the header is already fine, this bug is for the sunpro compiler.

What do you think about this patch?

--- a/include/curl/system.h
+++ b/include/curl/system.h
@@ -368,10 +368,35 @@
 #  define CURL_SUFFIX_CURL_OFF_TU    ULL
 #  define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
 #  define CURL_PULL_SYS_TYPES_H      1
 #  define CURL_PULL_SYS_SOCKET_H     1
 
+#elif defined(__SUNPRO_C) /* Oracle Solaris Studio */
+#  if !defined(__LP64) && (defined(__ILP32) ||                          \
+                           defined(__i386) || defined(__sparcv8))
+#    define CURL_SIZEOF_LONG           4
+#    define CURL_TYPEOF_CURL_OFF_T     long long
+#    define CURL_FORMAT_CURL_OFF_T     "lld"
+#    define CURL_FORMAT_CURL_OFF_TU    "llu"
+#    define CURL_SIZEOF_CURL_OFF_T     8
+#    define CURL_SUFFIX_CURL_OFF_T     LL
+#    define CURL_SUFFIX_CURL_OFF_TU    ULL
+#  elif defined(__LP64) || \
+        defined(__amd64) || defined(__sparcv9)
+#    define CURL_SIZEOF_LONG           8
+#    define CURL_TYPEOF_CURL_OFF_T     long
+#    define CURL_FORMAT_CURL_OFF_T     "ld"
+#    define CURL_FORMAT_CURL_OFF_TU    "lu"
+#    define CURL_SIZEOF_CURL_OFF_T     8
+#    define CURL_SUFFIX_CURL_OFF_T     L
+#    define CURL_SUFFIX_CURL_OFF_TU    UL
+#  endif
+#  define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+#  define CURL_SIZEOF_CURL_SOCKLEN_T 4
+#  define CURL_PULL_SYS_TYPES_H      1
+#  define CURL_PULL_SYS_SOCKET_H     1
+
 /* ===================================== */
 /*    KEEP MSVC THE PENULTIMATE ENTRY    */
 /* ===================================== */
 
 #elif defined(_MSC_VER)

@dago
Copy link
Contributor Author

dago commented Aug 12, 2017

I can confirm that this patch fixes the issue ob both Sparc and x86.

@bagder
Copy link
Member

bagder commented Aug 12, 2017

Excellent, thank you!

@bagder bagder closed this as completed in 7c71199 Aug 12, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants