From 909f3a9c8dac5d15c2492c008e370be60f50b50c Mon Sep 17 00:00:00 2001 From: "Serge S. Gulin" <gulin.serge@gmail.com> Date: Sun, 14 Apr 2024 23:58:43 +0400 Subject: [PATCH] JS: Disable js linker warning for empty symbol table to make js tests running consistent across environments --- compiler/GHC/StgToJS/Linker/Linker.hs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/compiler/GHC/StgToJS/Linker/Linker.hs b/compiler/GHC/StgToJS/Linker/Linker.hs index 67fa8b344b0c..117cf5868dfc 100644 --- a/compiler/GHC/StgToJS/Linker/Linker.hs +++ b/compiler/GHC/StgToJS/Linker/Linker.hs @@ -284,9 +284,30 @@ jsLink lc_cfg cfg logger tmpfs ar_cache out link_plan = do hPutChar h '\n' let emcc_opts' = emcc_opts <> opts go_entries emcc_opts' cc_objs es - Nothing -> do - logInfo logger (vcat [text "Ignoring unexpected archive entry: ", text (Ar.filename e)]) - go_entries emcc_opts cc_objs es + Nothing -> case Ar.filename e of + -- JavaScript code linker does not support symbol table processing. + -- Currently the linker does nothing when the symbol table is met. + -- Ar/Ranlib usually do not create a record for the symbol table + -- in the object archive when the table has no entries. + -- For JavaScript code it should not be created by default. + + "__.SYMDEF" -> + -- GNU Ar added the symbol table. + + -- Emscripten Ar (at least 3.1.24 version) + -- adds it even when the symbol table is empty. + go_entries emcc_opts cc_objs es + "__.SYMDEF SORTED" -> + -- BSD-like Ar added the symbol table. + + -- By default, Clang Ar does not add it when the + -- symbol table is empty (and it should be empty) but we left + -- it here to handle the case with symbol table completely + -- for GNU and BSD tools. + go_entries emcc_opts cc_objs es + unknown_name -> do + logInfo logger (vcat [text "Ignoring unexpected archive entry: ", text unknown_name]) + go_entries emcc_opts cc_objs es -- additional JS objects (e.g. from the command-line) go_extra emcc_opts = \case -- GitLab