diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-02-05 23:12:07 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-04-06 13:01:28 -0400 |
commit | 400666c81af024b6d16100aba88c2e8e78e8eef8 (patch) | |
tree | 08324c14136e7fd92fa20769f9e25c280a0eeb35 /rts/Linker.c | |
parent | 410c76eea7370f2d1143cf79aa524fcdec184f89 (diff) | |
download | haskell-400666c81af024b6d16100aba88c2e8e78e8eef8.tar.gz |
rts/linker: Catch archives masquerading as object files
Check the file's header to catch static archive bearing the `.o`
extension, as may happen on Windows after the Clang refactoring.
See #21068
Diffstat (limited to 'rts/Linker.c')
-rw-r--r-- | rts/Linker.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/rts/Linker.c b/rts/Linker.c index a98f0bd2cb..88734bd597 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -1356,7 +1356,7 @@ preloadObjectFile (pathchar *path) image = stgMallocBytes(fileSize, "loadObj(image)"); -#endif +#endif /* !defined(darwin_HOST_OS) */ int n; n = fread ( image, 1, fileSize, f ); @@ -1401,6 +1401,15 @@ static HsInt loadObj_ (pathchar *path) return 1; // success } + if (isArchive(path)) { + if (loadArchive_(path)) { + return 1; // success + } else { + IF_DEBUG(linker, + debugBelch("tried and failed to load %" PATH_FMT " as an archive\n", path)); + } + } + ObjectCode *oc = preloadObjectFile(path); if (oc == NULL) return 0; |