-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix build on systems that require -lm (re: 4edfa45)
@JohnoKing reports: > Ksh now fails to build on the specified operating systems unless > -lm is added to LDFLAGS when invoking bin/package. Failing to > manually add -lm results in missing symbol errors for functions > such as frexpl. The build is confirmed to fail upon linking the libast version of mamake on NetBSD, DragonflyBSD and Illumos. Analysis: The root cause of the problem is that the probe in src/lib/libast/Mamfile, lines 276-301, fails to add a '-lm' line to ast.req. This probe is designed to figure out is math functions are dependent on libm. It compiles/links src/lib/libast/port/astmath.c for a number of values of the macro N, trying a different math function each time. If any one of them fails without '-lm' but succeeds with '-lm', the '-lm' is added to libast's dependencies as processed by mamake. The problem is that the probe function calls in astmath.c get optimised out because their values, and hence the results, are known at compile time -- so linking succeeds where it should fail. When compiling with -O0 to disable optimisation, the probe works correctly, -lm is added to ast.req (so mamake includes it in the mam_libast MAM variable), and the build succeeds on NetBSD without any problem. So, the fix is for astmath.c to work around compiler optimisation. This fixes an old problem in the build system. With the root cause fixed, we are now also able to remove a bunch of -lm workarounds. src/lib/libast/port/astmath.c: - Replace fixed 0 values with rand() calls to avoid probe call results being known at compile time. src/lib/libast/Mamfile: - For some reason, the N=7 astmath.c case was not tried; add it. - Tweaks to error out early in case of failure. src/cmd/builtin/Mamfile, src/cmd/ksh93/Mamfile, src/cmd/builtin/features/pty: - Remove -lm workarounds. (re: 2b27f63, d79a34b/22e044c3, dd0d03b, d3cd4cf, and even AT&T) Resolves: #715
- Loading branch information
Showing
5 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters