Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 49d9017bfc7a5ba05d1b810e985960c2fa09a0c8a9ef4d7581d11c1d98c0321f
Ticket: 713653b951c625ef974f5f06b2e96634ca5fb1f9
Floating point precision problems on x86 musl
User & Date: rubicon on 2022-07-15 04:22:53
Changes

  1. icomment:
    I'll try to answer the questions as best as I can, but as I am a little under the weather today, I may be a bit slow.
    
    > what compiler is this?
    
    GCC 11.2.1
    
    > Are you changing optimization flags
    
    Alpine Linux's build system sets the following environment variables ( from https://git.alpinelinux.org/abuild/tree/abuild.conf ):
    
    export CFLAGS="-Os -fomit-frame-pointer"
    export CXXFLAGS="$CFLAGS"
    export CPPFLAGS="$CFLAGS"
    export LDFLAGS="-Wl,--as-needed,-O1,--sort-common"
    
    > You did say that everything in Tcl's own tests passed before you started adjusting the rounding modes, right?
    
    Sorry for not clarifying this better.
    
    The expr tests (that I linked to, but which is no longer attached to this bug report) fail when I adjust the rounding modes.
    
    The expr-old and format tests which are still attached fail together with the Tcllib math tests.
    
    > I've not found that to be necessary at the -O2 setting that Tcl uses by default
    
    Alpine uses -Os, is this likely the source of the problem?
    
    > the next thing that I'd suspect is that something is messed up in the C library
    
    Through trial and error (as I am not a C programmer), after commenting the following lines in MakeLowPrecisionDouble:
    
        if (significand == 0) {
    	return copysign(0.0, -signum);
        }
    
    Both Tcl's expr-old and format tests and Tcllib's math and units tests all pass.
    
    Alpine is now using musl v1.2.3, which has this implementation of copysign: https://git.musl-libc.org/cgit/musl/tree/src/math/copysign.c?h=v1.2.3
    
    > Are we sure that 8.6.10 and 8.6.11 were built with the same compiler, include files, system libraries and optimization flags?
    
    I tested 8.6.10 and 8.6.11 in a Gitlab CI within about an hour of each other, I don't think anything changed within that short period of time.
    
  2. login: "rubicon"
  3. mimetype: "text/plain"