https://bz.apache.org/ooo/show_bug.cgi?id=127712

          Issue ID: 127712
        Issue Type: DEFECT
           Summary: Allow building when gcc -dumpversion does not use the
                    canonical x.y.z format
           Product: Build Tools
           Version: 4.2.0-dev
          Hardware: All
                OS: All
            Status: CONFIRMED
          Severity: Normal
          Priority: P5 (lowest)
         Component: solenv
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Code in main/solenv/inc/tg_compv.mk and main/solenv/bin/getcompver.awk assumes
that "gcc -dumpversion" will return a canonical version number in the form
x.y.z.

Unfortunately, recent GCC versions no longer guarantee this convention:

https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#index-dumpversion

"Print the compiler version (for example, 3.0, 6.3.0 or 7)—and don’t do
anything else. This is the compiler version used in filesystem paths, specs,
can be depending on how the compiler has been configured just a single number
(major version), two numbers separated by dot (major and minor version) or
three numbers separated by dots (major, minor and patchlevel version)."

The right one to use would be -dumpfullversion (same URL):

"Print the full compiler version, always 3 numbers separated by dots, major,
minor and patchlevel version."

Unfortunately, it seems (but I haven't checked yet) that old gcc versions do
not support -dumpfullversion.

Note: "6.3" does not mean "6.3.0"; you can get "6.3" for "6.3.0" or "6.3.1",
and you can get "7" for "7.0.0", "7.3.0", "7.3.1"... the version is simply
truncated, and configuration depends on the distribution.

When the output is in the form "x.y", we already expand it to "x.y.0", which is
wrong (see above).

The following patch to main/solenv/bin/getcompver.awk extends it to expand "7"
to "7.0.0" and is equally wrong, but it allows the build to continue.

---
@@ -46,6 +46,13 @@
     x = match( $0, /[0-9]*\.[0-9]*\.[0-9]*/ )
     CCversion = substr( $0, RSTART, RLENGTH)
 }
+/^[0-9]*\x0d*$/ {
+    if ( compiler_matched == 0 ) {
+    # Comparison assumes the compiler version is reported as x.y.z.
+    # For GCC one should use -dumpfullversion but it won't work on old
versions.
+       CCversion = $0 ".0.0"
+    }
+}
 /^[0-9]*[.][0-9]*\x0d*$/ {
     if ( compiler_matched == 0 ) {
 # need to blow to x.xx.xx for comparing
---

The proper solution is: test if -dumpfullversion is supported and use its
output in case, otherwise revert to -dumpversion and go through all current
hacks.

Note that the awk file is not specific to gcc, so changes must go in
main/solenv/inc/tg_compv.mk

-- 
You are receiving this mail because:
You are the assignee for the issue.

Reply via email to