From 9748dd040a3393b13aa84d3f9f4166bc078a270e Mon Sep 17 00:00:00 2001 From: Divam Date: Sun, 1 Jul 2018 15:34:04 +0900 Subject: [PATCH 1/4] Stop RtsSymbol table generation in wasm, as linker gives type mismatch error. --- rts/RtsSymbols.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c index 22a1670b359f..68f7a11c2bd1 100644 --- a/rts/RtsSymbols.c +++ b/rts/RtsSymbols.c @@ -1018,6 +1018,9 @@ RTS_LIBFFI_SYMBOLS { #vvv, (void*)0xBAADF00D, true }, RtsSymbolVal rtsSyms[] = { +// Wasm doesn't support dynamic linking, and it complains if there is a type mismatch +// So a simple workaround is not to declare the symbol table. +#if !defined (__wasm__) RTS_SYMBOLS RTS_RET_SYMBOLS RTS_POSIX_ONLY_SYMBOLS @@ -1035,5 +1038,6 @@ RtsSymbolVal rtsSyms[] = { // lazy pointers as nonlazy. { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false }, #endif +#endif /* wasm32_HOST_ARCH */ { 0, 0, false } /* sentinel */ }; From 25fd1f91778c53fa837f303cafe35252cc52cda2 Mon Sep 17 00:00:00 2001 From: Divam Date: Sun, 1 Jul 2018 16:44:03 +0900 Subject: [PATCH 2/4] Add dummy arg to barf calls in cmm files. This prevents the linker error in wasm. --- rts/Apply.cmm | 2 +- rts/StgMiscClosures.cmm | 88 ++++++++++++++++++++--------------------- rts/StgStartup.cmm | 2 +- utils/genapply/Main.hs | 2 +- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/rts/Apply.cmm b/rts/Apply.cmm index 15d8250f5228..4c825c8dedb3 100644 --- a/rts/Apply.cmm +++ b/rts/Apply.cmm @@ -206,7 +206,7 @@ again: -------------------------------------------------------------------------- */ INFO_TABLE(stg_PAP,/*special layout*/0,0,PAP,"PAP","PAP") -{ ccall barf("PAP object entered!") never returns; } +{ ccall barf("PAP object entered!", 0) never returns; } stg_PAP_apply /* no args => explicit stack */ { diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 9fd5fb8b88ab..2872b782aa58 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -354,11 +354,11 @@ INFO_TABLE(__stg_EAGER_BLACKHOLE,1,0,BLACKHOLE,"BLACKHOLE","BLACKHOLE") } INFO_TABLE(stg_BLOCKING_QUEUE_CLEAN,4,0,BLOCKING_QUEUE,"BLOCKING_QUEUE","BLOCKING_QUEUE") -{ foreign "C" barf("BLOCKING_QUEUE_CLEAN object entered!") never returns; } +{ foreign "C" barf("BLOCKING_QUEUE_CLEAN object entered!", 0) never returns; } INFO_TABLE(stg_BLOCKING_QUEUE_DIRTY,4,0,BLOCKING_QUEUE,"BLOCKING_QUEUE","BLOCKING_QUEUE") -{ foreign "C" barf("BLOCKING_QUEUE_DIRTY object entered!") never returns; } +{ foreign "C" barf("BLOCKING_QUEUE_DIRTY object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- @@ -395,7 +395,7 @@ loop: } jump %ENTRY_CODE(info) (node); #else - ccall barf("WHITEHOLE object entered!") never returns; + ccall barf("WHITEHOLE object entered!", 0) never returns; #endif } @@ -406,10 +406,10 @@ loop: ------------------------------------------------------------------------- */ INFO_TABLE(stg_TSO, 0,0,TSO, "TSO", "TSO") -{ foreign "C" barf("TSO object entered!") never returns; } +{ foreign "C" barf("TSO object entered!", 0) never returns; } INFO_TABLE(stg_STACK, 0,0, STACK, "STACK", "STACK") -{ foreign "C" barf("STACK object entered!") never returns; } +{ foreign "C" barf("STACK object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- Weak pointers @@ -420,7 +420,7 @@ INFO_TABLE(stg_STACK, 0,0, STACK, "STACK", "STACK") ------------------------------------------------------------------------- */ INFO_TABLE(stg_WEAK,1,4,WEAK,"WEAK","WEAK") -{ foreign "C" barf("WEAK object entered!") never returns; } +{ foreign "C" barf("WEAK object entered!", 0) never returns; } /* * It's important when turning an existing WEAK into a DEAD_WEAK @@ -429,7 +429,7 @@ INFO_TABLE(stg_WEAK,1,4,WEAK,"WEAK","WEAK") * DEAD_WEAK 5 non-pointer fields. */ INFO_TABLE_CONSTR(stg_DEAD_WEAK,0,5,0,CONSTR,"DEAD_WEAK","DEAD_WEAK") -{ foreign "C" barf("DEAD_WEAK object entered!") never returns; } +{ foreign "C" barf("DEAD_WEAK object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- C finalizer lists @@ -438,7 +438,7 @@ INFO_TABLE_CONSTR(stg_DEAD_WEAK,0,5,0,CONSTR,"DEAD_WEAK","DEAD_WEAK") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_C_FINALIZER_LIST,1,4,0,CONSTR,"C_FINALIZER_LIST","C_FINALIZER_LIST") -{ foreign "C" barf("C_FINALIZER_LIST object entered!") never returns; } +{ foreign "C" barf("C_FINALIZER_LIST object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- NO_FINALIZER @@ -448,7 +448,7 @@ INFO_TABLE_CONSTR(stg_C_FINALIZER_LIST,1,4,0,CONSTR,"C_FINALIZER_LIST","C_FINALI ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_NO_FINALIZER,0,0,0,CONSTR_NOCAF,"NO_FINALIZER","NO_FINALIZER") -{ foreign "C" barf("NO_FINALIZER object entered!") never returns; } +{ foreign "C" barf("NO_FINALIZER object entered!", 0) never returns; } CLOSURE(stg_NO_FINALIZER_closure,stg_NO_FINALIZER); @@ -457,7 +457,7 @@ CLOSURE(stg_NO_FINALIZER_closure,stg_NO_FINALIZER); ------------------------------------------------------------------------- */ INFO_TABLE(stg_STABLE_NAME,0,1,PRIM,"STABLE_NAME","STABLE_NAME") -{ foreign "C" barf("STABLE_NAME object entered!") never returns; } +{ foreign "C" barf("STABLE_NAME object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- MVars @@ -467,47 +467,47 @@ INFO_TABLE(stg_STABLE_NAME,0,1,PRIM,"STABLE_NAME","STABLE_NAME") ------------------------------------------------------------------------- */ INFO_TABLE(stg_MVAR_CLEAN,3,0,MVAR_CLEAN,"MVAR","MVAR") -{ foreign "C" barf("MVAR object entered!") never returns; } +{ foreign "C" barf("MVAR object entered!", 0) never returns; } INFO_TABLE(stg_MVAR_DIRTY,3,0,MVAR_DIRTY,"MVAR","MVAR") -{ foreign "C" barf("MVAR object entered!") never returns; } +{ foreign "C" barf("MVAR object entered!", 0) never returns; } /* ----------------------------------------------------------------------------- STM -------------------------------------------------------------------------- */ INFO_TABLE(stg_TVAR_CLEAN, 2, 1, TVAR, "TVAR", "TVAR") -{ foreign "C" barf("TVAR_CLEAN object entered!") never returns; } +{ foreign "C" barf("TVAR_CLEAN object entered!", 0) never returns; } INFO_TABLE(stg_TVAR_DIRTY, 2, 1, TVAR, "TVAR", "TVAR") -{ foreign "C" barf("TVAR_DIRTY object entered!") never returns; } +{ foreign "C" barf("TVAR_DIRTY object entered!", 0) never returns; } INFO_TABLE(stg_TVAR_WATCH_QUEUE, 3, 0, MUT_PRIM, "TVAR_WATCH_QUEUE", "TVAR_WATCH_QUEUE") -{ foreign "C" barf("TVAR_WATCH_QUEUE object entered!") never returns; } +{ foreign "C" barf("TVAR_WATCH_QUEUE object entered!", 0) never returns; } INFO_TABLE(stg_ATOMIC_INVARIANT, 2, 1, MUT_PRIM, "ATOMIC_INVARIANT", "ATOMIC_INVARIANT") -{ foreign "C" barf("ATOMIC_INVARIANT object entered!") never returns; } +{ foreign "C" barf("ATOMIC_INVARIANT object entered!", 0) never returns; } INFO_TABLE(stg_INVARIANT_CHECK_QUEUE, 3, 0, MUT_PRIM, "INVARIANT_CHECK_QUEUE", "INVARIANT_CHECK_QUEUE") -{ foreign "C" barf("INVARIANT_CHECK_QUEUE object entered!") never returns; } +{ foreign "C" barf("INVARIANT_CHECK_QUEUE object entered!", 0) never returns; } INFO_TABLE(stg_TREC_CHUNK, 0, 0, TREC_CHUNK, "TREC_CHUNK", "TREC_CHUNK") -{ foreign "C" barf("TREC_CHUNK object entered!") never returns; } +{ foreign "C" barf("TREC_CHUNK object entered!", 0) never returns; } INFO_TABLE(stg_TREC_HEADER, 3, 1, MUT_PRIM, "TREC_HEADER", "TREC_HEADER") -{ foreign "C" barf("TREC_HEADER object entered!") never returns; } +{ foreign "C" barf("TREC_HEADER object entered!", 0) never returns; } INFO_TABLE_CONSTR(stg_END_STM_WATCH_QUEUE,0,0,0,CONSTR_NOCAF,"END_STM_WATCH_QUEUE","END_STM_WATCH_QUEUE") -{ foreign "C" barf("END_STM_WATCH_QUEUE object entered!") never returns; } +{ foreign "C" barf("END_STM_WATCH_QUEUE object entered!", 0) never returns; } INFO_TABLE_CONSTR(stg_END_INVARIANT_CHECK_QUEUE,0,0,0,CONSTR_NOCAF,"END_INVARIANT_CHECK_QUEUE","END_INVARIANT_CHECK_QUEUE") -{ foreign "C" barf("END_INVARIANT_CHECK_QUEUE object entered!") never returns; } +{ foreign "C" barf("END_INVARIANT_CHECK_QUEUE object entered!", 0) never returns; } INFO_TABLE_CONSTR(stg_END_STM_CHUNK_LIST,0,0,0,CONSTR_NOCAF,"END_STM_CHUNK_LIST","END_STM_CHUNK_LIST") -{ foreign "C" barf("END_STM_CHUNK_LIST object entered!") never returns; } +{ foreign "C" barf("END_STM_CHUNK_LIST object entered!", 0) never returns; } INFO_TABLE_CONSTR(stg_NO_TREC,0,0,0,CONSTR_NOCAF,"NO_TREC","NO_TREC") -{ foreign "C" barf("NO_TREC object entered!") never returns; } +{ foreign "C" barf("NO_TREC object entered!", 0) never returns; } CLOSURE(stg_END_STM_WATCH_QUEUE_closure,stg_END_STM_WATCH_QUEUE); @@ -524,17 +524,17 @@ CLOSURE(stg_NO_TREC_closure,stg_NO_TREC); // PRIM rather than CONSTR, because PRIM objects cannot be duplicated by the GC. INFO_TABLE_CONSTR(stg_MSG_TRY_WAKEUP,2,0,0,PRIM,"MSG_TRY_WAKEUP","MSG_TRY_WAKEUP") -{ foreign "C" barf("MSG_TRY_WAKEUP object entered!") never returns; } +{ foreign "C" barf("MSG_TRY_WAKEUP object entered!", 0) never returns; } INFO_TABLE_CONSTR(stg_MSG_THROWTO,4,0,0,PRIM,"MSG_THROWTO","MSG_THROWTO") -{ foreign "C" barf("MSG_THROWTO object entered!") never returns; } +{ foreign "C" barf("MSG_THROWTO object entered!", 0) never returns; } INFO_TABLE_CONSTR(stg_MSG_BLACKHOLE,3,0,0,PRIM,"MSG_BLACKHOLE","MSG_BLACKHOLE") -{ foreign "C" barf("MSG_BLACKHOLE object entered!") never returns; } +{ foreign "C" barf("MSG_BLACKHOLE object entered!", 0) never returns; } // used to overwrite a MSG_THROWTO when the message has been used/revoked INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") -{ foreign "C" barf("MSG_NULL object entered!") never returns; } +{ foreign "C" barf("MSG_NULL object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- END_TSO_QUEUE @@ -544,7 +544,7 @@ INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_END_TSO_QUEUE,0,0,0,CONSTR_NOCAF,"END_TSO_QUEUE","END_TSO_QUEUE") -{ foreign "C" barf("END_TSO_QUEUE object entered!") never returns; } +{ foreign "C" barf("END_TSO_QUEUE object entered!", 0) never returns; } CLOSURE(stg_END_TSO_QUEUE_closure,stg_END_TSO_QUEUE); @@ -553,7 +553,7 @@ CLOSURE(stg_END_TSO_QUEUE_closure,stg_END_TSO_QUEUE); ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_GCD_CAF,0,0,0,CONSTR_NOCAF,"GCD_CAF","GCD_CAF") -{ foreign "C" barf("Evaluated a CAF that was GC'd!") never returns; } +{ foreign "C" barf("Evaluated a CAF that was GC'd!", 0) never returns; } /* ---------------------------------------------------------------------------- STM_AWOKEN @@ -563,7 +563,7 @@ INFO_TABLE_CONSTR(stg_GCD_CAF,0,0,0,CONSTR_NOCAF,"GCD_CAF","GCD_CAF") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_STM_AWOKEN,0,0,0,CONSTR_NOCAF,"STM_AWOKEN","STM_AWOKEN") -{ foreign "C" barf("STM_AWOKEN object entered!") never returns; } +{ foreign "C" barf("STM_AWOKEN object entered!", 0) never returns; } CLOSURE(stg_STM_AWOKEN_closure,stg_STM_AWOKEN); @@ -583,40 +583,40 @@ CLOSURE(stg_STM_AWOKEN_closure,stg_STM_AWOKEN); ------------------------------------------------------------------------- */ INFO_TABLE(stg_ARR_WORDS, 0, 0, ARR_WORDS, "ARR_WORDS", "ARR_WORDS") -{ foreign "C" barf("ARR_WORDS object entered!") never returns; } +{ foreign "C" barf("ARR_WORDS object entered!", 0) never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_CLEAN, 0, 0, MUT_ARR_PTRS_CLEAN, "MUT_ARR_PTRS_CLEAN", "MUT_ARR_PTRS_CLEAN") -{ foreign "C" barf("MUT_ARR_PTRS_CLEAN object entered!") never returns; } +{ foreign "C" barf("MUT_ARR_PTRS_CLEAN object entered!", 0) never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_DIRTY, 0, 0, MUT_ARR_PTRS_DIRTY, "MUT_ARR_PTRS_DIRTY", "MUT_ARR_PTRS_DIRTY") -{ foreign "C" barf("MUT_ARR_PTRS_DIRTY object entered!") never returns; } +{ foreign "C" barf("MUT_ARR_PTRS_DIRTY object entered!", 0) never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_FROZEN, 0, 0, MUT_ARR_PTRS_FROZEN, "MUT_ARR_PTRS_FROZEN", "MUT_ARR_PTRS_FROZEN") -{ foreign "C" barf("MUT_ARR_PTRS_FROZEN object entered!") never returns; } +{ foreign "C" barf("MUT_ARR_PTRS_FROZEN object entered!", 0) never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_FROZEN0, 0, 0, MUT_ARR_PTRS_FROZEN0, "MUT_ARR_PTRS_FROZEN0", "MUT_ARR_PTRS_FROZEN0") -{ foreign "C" barf("MUT_ARR_PTRS_FROZEN0 object entered!") never returns; } +{ foreign "C" barf("MUT_ARR_PTRS_FROZEN0 object entered!", 0) never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_CLEAN, 0, 0, SMALL_MUT_ARR_PTRS_CLEAN, "SMALL_MUT_ARR_PTRS_CLEAN", "SMALL_MUT_ARR_PTRS_CLEAN") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_CLEAN object entered!") never returns; } +{ foreign "C" barf("SMALL_MUT_ARR_PTRS_CLEAN object entered!", 0) never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_DIRTY, 0, 0, SMALL_MUT_ARR_PTRS_DIRTY, "SMALL_MUT_ARR_PTRS_DIRTY", "SMALL_MUT_ARR_PTRS_DIRTY") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_DIRTY object entered!") never returns; } +{ foreign "C" barf("SMALL_MUT_ARR_PTRS_DIRTY object entered!", 0) never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_FROZEN, 0, 0, SMALL_MUT_ARR_PTRS_FROZEN, "SMALL_MUT_ARR_PTRS_FROZEN", "SMALL_MUT_ARR_PTRS_FROZEN") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN object entered!") never returns; } +{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN object entered!", 0) never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_FROZEN0, 0, 0, SMALL_MUT_ARR_PTRS_FROZEN0, "SMALL_MUT_ARR_PTRS_FROZEN0", "SMALL_MUT_ARR_PTRS_FROZEN0") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN0 object entered!") never returns; } +{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN0 object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- Mutable Variables ------------------------------------------------------------------------- */ INFO_TABLE(stg_MUT_VAR_CLEAN, 1, 0, MUT_VAR_CLEAN, "MUT_VAR_CLEAN", "MUT_VAR_CLEAN") -{ foreign "C" barf("MUT_VAR_CLEAN object entered!") never returns; } +{ foreign "C" barf("MUT_VAR_CLEAN object entered!", 0) never returns; } INFO_TABLE(stg_MUT_VAR_DIRTY, 1, 0, MUT_VAR_DIRTY, "MUT_VAR_DIRTY", "MUT_VAR_DIRTY") -{ foreign "C" barf("MUT_VAR_DIRTY object entered!") never returns; } +{ foreign "C" barf("MUT_VAR_DIRTY object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- Dummy return closure @@ -638,7 +638,7 @@ CLOSURE(stg_dummy_ret_closure,stg_dummy_ret); ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE") -{ foreign "C" barf("MVAR_TSO_QUEUE object entered!") never returns; } +{ foreign "C" barf("MVAR_TSO_QUEUE object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- COMPACT_NFDATA (a blob of data in NF with no outgoing pointers) @@ -651,11 +651,11 @@ INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE INFO_TABLE( stg_COMPACT_NFDATA_CLEAN, 0, 5, COMPACT_NFDATA, "COMPACT_NFDATA", "COMPACT_NFDATA") () -{ foreign "C" barf("COMPACT_NFDATA_CLEAN object entered!") never returns; } +{ foreign "C" barf("COMPACT_NFDATA_CLEAN object entered!", 0) never returns; } INFO_TABLE( stg_COMPACT_NFDATA_DIRTY, 0, 5, COMPACT_NFDATA, "COMPACT_NFDATA", "COMPACT_NFDATA") () -{ foreign "C" barf("COMPACT_NFDATA_DIRTY object entered!") never returns; } +{ foreign "C" barf("COMPACT_NFDATA_DIRTY object entered!", 0) never returns; } /* ---------------------------------------------------------------------------- CHARLIKE and INTLIKE closures. diff --git a/rts/StgStartup.cmm b/rts/StgStartup.cmm index f67373031bfc..036e4eeff562 100644 --- a/rts/StgStartup.cmm +++ b/rts/StgStartup.cmm @@ -185,5 +185,5 @@ INFO_TABLE_RET(stg_forceIO, RET_SMALL, P_ info_ptr) /* Called when compiled with -falignment-sanitisation on alignment failure */ stg_badAlignment_entry { - foreign "C" barf(); + foreign "C" barf("", 0); } diff --git a/utils/genapply/Main.hs b/utils/genapply/Main.hs index b30c9f8c46ac..df2fcfa2bd59 100644 --- a/utils/genapply/Main.hs +++ b/utils/genapply/Main.hs @@ -789,7 +789,7 @@ genApply regstatus args = text "default: {", nest 4 ( - text "foreign \"C\" barf(\"" <> fun_ret_label <> text "\") never returns;" + text "foreign \"C\" barf(\"" <> fun_ret_label <> text "\", 0) never returns;" ), text "}" From 1b4174ce7d9471fc841bd3ee324e220deba90bd7 Mon Sep 17 00:00:00 2001 From: Divam Date: Mon, 2 Jul 2018 16:48:52 +0900 Subject: [PATCH 3/4] Revert "Add dummy arg to barf calls in cmm files." This reverts commit 177e3388ecd8dd1e0f5241db18f81a8050464626. --- rts/Apply.cmm | 2 +- rts/StgMiscClosures.cmm | 88 ++++++++++++++++++++--------------------- rts/StgStartup.cmm | 2 +- utils/genapply/Main.hs | 2 +- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/rts/Apply.cmm b/rts/Apply.cmm index 4c825c8dedb3..15d8250f5228 100644 --- a/rts/Apply.cmm +++ b/rts/Apply.cmm @@ -206,7 +206,7 @@ again: -------------------------------------------------------------------------- */ INFO_TABLE(stg_PAP,/*special layout*/0,0,PAP,"PAP","PAP") -{ ccall barf("PAP object entered!", 0) never returns; } +{ ccall barf("PAP object entered!") never returns; } stg_PAP_apply /* no args => explicit stack */ { diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 2872b782aa58..9fd5fb8b88ab 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -354,11 +354,11 @@ INFO_TABLE(__stg_EAGER_BLACKHOLE,1,0,BLACKHOLE,"BLACKHOLE","BLACKHOLE") } INFO_TABLE(stg_BLOCKING_QUEUE_CLEAN,4,0,BLOCKING_QUEUE,"BLOCKING_QUEUE","BLOCKING_QUEUE") -{ foreign "C" barf("BLOCKING_QUEUE_CLEAN object entered!", 0) never returns; } +{ foreign "C" barf("BLOCKING_QUEUE_CLEAN object entered!") never returns; } INFO_TABLE(stg_BLOCKING_QUEUE_DIRTY,4,0,BLOCKING_QUEUE,"BLOCKING_QUEUE","BLOCKING_QUEUE") -{ foreign "C" barf("BLOCKING_QUEUE_DIRTY object entered!", 0) never returns; } +{ foreign "C" barf("BLOCKING_QUEUE_DIRTY object entered!") never returns; } /* ---------------------------------------------------------------------------- @@ -395,7 +395,7 @@ loop: } jump %ENTRY_CODE(info) (node); #else - ccall barf("WHITEHOLE object entered!", 0) never returns; + ccall barf("WHITEHOLE object entered!") never returns; #endif } @@ -406,10 +406,10 @@ loop: ------------------------------------------------------------------------- */ INFO_TABLE(stg_TSO, 0,0,TSO, "TSO", "TSO") -{ foreign "C" barf("TSO object entered!", 0) never returns; } +{ foreign "C" barf("TSO object entered!") never returns; } INFO_TABLE(stg_STACK, 0,0, STACK, "STACK", "STACK") -{ foreign "C" barf("STACK object entered!", 0) never returns; } +{ foreign "C" barf("STACK object entered!") never returns; } /* ---------------------------------------------------------------------------- Weak pointers @@ -420,7 +420,7 @@ INFO_TABLE(stg_STACK, 0,0, STACK, "STACK", "STACK") ------------------------------------------------------------------------- */ INFO_TABLE(stg_WEAK,1,4,WEAK,"WEAK","WEAK") -{ foreign "C" barf("WEAK object entered!", 0) never returns; } +{ foreign "C" barf("WEAK object entered!") never returns; } /* * It's important when turning an existing WEAK into a DEAD_WEAK @@ -429,7 +429,7 @@ INFO_TABLE(stg_WEAK,1,4,WEAK,"WEAK","WEAK") * DEAD_WEAK 5 non-pointer fields. */ INFO_TABLE_CONSTR(stg_DEAD_WEAK,0,5,0,CONSTR,"DEAD_WEAK","DEAD_WEAK") -{ foreign "C" barf("DEAD_WEAK object entered!", 0) never returns; } +{ foreign "C" barf("DEAD_WEAK object entered!") never returns; } /* ---------------------------------------------------------------------------- C finalizer lists @@ -438,7 +438,7 @@ INFO_TABLE_CONSTR(stg_DEAD_WEAK,0,5,0,CONSTR,"DEAD_WEAK","DEAD_WEAK") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_C_FINALIZER_LIST,1,4,0,CONSTR,"C_FINALIZER_LIST","C_FINALIZER_LIST") -{ foreign "C" barf("C_FINALIZER_LIST object entered!", 0) never returns; } +{ foreign "C" barf("C_FINALIZER_LIST object entered!") never returns; } /* ---------------------------------------------------------------------------- NO_FINALIZER @@ -448,7 +448,7 @@ INFO_TABLE_CONSTR(stg_C_FINALIZER_LIST,1,4,0,CONSTR,"C_FINALIZER_LIST","C_FINALI ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_NO_FINALIZER,0,0,0,CONSTR_NOCAF,"NO_FINALIZER","NO_FINALIZER") -{ foreign "C" barf("NO_FINALIZER object entered!", 0) never returns; } +{ foreign "C" barf("NO_FINALIZER object entered!") never returns; } CLOSURE(stg_NO_FINALIZER_closure,stg_NO_FINALIZER); @@ -457,7 +457,7 @@ CLOSURE(stg_NO_FINALIZER_closure,stg_NO_FINALIZER); ------------------------------------------------------------------------- */ INFO_TABLE(stg_STABLE_NAME,0,1,PRIM,"STABLE_NAME","STABLE_NAME") -{ foreign "C" barf("STABLE_NAME object entered!", 0) never returns; } +{ foreign "C" barf("STABLE_NAME object entered!") never returns; } /* ---------------------------------------------------------------------------- MVars @@ -467,47 +467,47 @@ INFO_TABLE(stg_STABLE_NAME,0,1,PRIM,"STABLE_NAME","STABLE_NAME") ------------------------------------------------------------------------- */ INFO_TABLE(stg_MVAR_CLEAN,3,0,MVAR_CLEAN,"MVAR","MVAR") -{ foreign "C" barf("MVAR object entered!", 0) never returns; } +{ foreign "C" barf("MVAR object entered!") never returns; } INFO_TABLE(stg_MVAR_DIRTY,3,0,MVAR_DIRTY,"MVAR","MVAR") -{ foreign "C" barf("MVAR object entered!", 0) never returns; } +{ foreign "C" barf("MVAR object entered!") never returns; } /* ----------------------------------------------------------------------------- STM -------------------------------------------------------------------------- */ INFO_TABLE(stg_TVAR_CLEAN, 2, 1, TVAR, "TVAR", "TVAR") -{ foreign "C" barf("TVAR_CLEAN object entered!", 0) never returns; } +{ foreign "C" barf("TVAR_CLEAN object entered!") never returns; } INFO_TABLE(stg_TVAR_DIRTY, 2, 1, TVAR, "TVAR", "TVAR") -{ foreign "C" barf("TVAR_DIRTY object entered!", 0) never returns; } +{ foreign "C" barf("TVAR_DIRTY object entered!") never returns; } INFO_TABLE(stg_TVAR_WATCH_QUEUE, 3, 0, MUT_PRIM, "TVAR_WATCH_QUEUE", "TVAR_WATCH_QUEUE") -{ foreign "C" barf("TVAR_WATCH_QUEUE object entered!", 0) never returns; } +{ foreign "C" barf("TVAR_WATCH_QUEUE object entered!") never returns; } INFO_TABLE(stg_ATOMIC_INVARIANT, 2, 1, MUT_PRIM, "ATOMIC_INVARIANT", "ATOMIC_INVARIANT") -{ foreign "C" barf("ATOMIC_INVARIANT object entered!", 0) never returns; } +{ foreign "C" barf("ATOMIC_INVARIANT object entered!") never returns; } INFO_TABLE(stg_INVARIANT_CHECK_QUEUE, 3, 0, MUT_PRIM, "INVARIANT_CHECK_QUEUE", "INVARIANT_CHECK_QUEUE") -{ foreign "C" barf("INVARIANT_CHECK_QUEUE object entered!", 0) never returns; } +{ foreign "C" barf("INVARIANT_CHECK_QUEUE object entered!") never returns; } INFO_TABLE(stg_TREC_CHUNK, 0, 0, TREC_CHUNK, "TREC_CHUNK", "TREC_CHUNK") -{ foreign "C" barf("TREC_CHUNK object entered!", 0) never returns; } +{ foreign "C" barf("TREC_CHUNK object entered!") never returns; } INFO_TABLE(stg_TREC_HEADER, 3, 1, MUT_PRIM, "TREC_HEADER", "TREC_HEADER") -{ foreign "C" barf("TREC_HEADER object entered!", 0) never returns; } +{ foreign "C" barf("TREC_HEADER object entered!") never returns; } INFO_TABLE_CONSTR(stg_END_STM_WATCH_QUEUE,0,0,0,CONSTR_NOCAF,"END_STM_WATCH_QUEUE","END_STM_WATCH_QUEUE") -{ foreign "C" barf("END_STM_WATCH_QUEUE object entered!", 0) never returns; } +{ foreign "C" barf("END_STM_WATCH_QUEUE object entered!") never returns; } INFO_TABLE_CONSTR(stg_END_INVARIANT_CHECK_QUEUE,0,0,0,CONSTR_NOCAF,"END_INVARIANT_CHECK_QUEUE","END_INVARIANT_CHECK_QUEUE") -{ foreign "C" barf("END_INVARIANT_CHECK_QUEUE object entered!", 0) never returns; } +{ foreign "C" barf("END_INVARIANT_CHECK_QUEUE object entered!") never returns; } INFO_TABLE_CONSTR(stg_END_STM_CHUNK_LIST,0,0,0,CONSTR_NOCAF,"END_STM_CHUNK_LIST","END_STM_CHUNK_LIST") -{ foreign "C" barf("END_STM_CHUNK_LIST object entered!", 0) never returns; } +{ foreign "C" barf("END_STM_CHUNK_LIST object entered!") never returns; } INFO_TABLE_CONSTR(stg_NO_TREC,0,0,0,CONSTR_NOCAF,"NO_TREC","NO_TREC") -{ foreign "C" barf("NO_TREC object entered!", 0) never returns; } +{ foreign "C" barf("NO_TREC object entered!") never returns; } CLOSURE(stg_END_STM_WATCH_QUEUE_closure,stg_END_STM_WATCH_QUEUE); @@ -524,17 +524,17 @@ CLOSURE(stg_NO_TREC_closure,stg_NO_TREC); // PRIM rather than CONSTR, because PRIM objects cannot be duplicated by the GC. INFO_TABLE_CONSTR(stg_MSG_TRY_WAKEUP,2,0,0,PRIM,"MSG_TRY_WAKEUP","MSG_TRY_WAKEUP") -{ foreign "C" barf("MSG_TRY_WAKEUP object entered!", 0) never returns; } +{ foreign "C" barf("MSG_TRY_WAKEUP object entered!") never returns; } INFO_TABLE_CONSTR(stg_MSG_THROWTO,4,0,0,PRIM,"MSG_THROWTO","MSG_THROWTO") -{ foreign "C" barf("MSG_THROWTO object entered!", 0) never returns; } +{ foreign "C" barf("MSG_THROWTO object entered!") never returns; } INFO_TABLE_CONSTR(stg_MSG_BLACKHOLE,3,0,0,PRIM,"MSG_BLACKHOLE","MSG_BLACKHOLE") -{ foreign "C" barf("MSG_BLACKHOLE object entered!", 0) never returns; } +{ foreign "C" barf("MSG_BLACKHOLE object entered!") never returns; } // used to overwrite a MSG_THROWTO when the message has been used/revoked INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") -{ foreign "C" barf("MSG_NULL object entered!", 0) never returns; } +{ foreign "C" barf("MSG_NULL object entered!") never returns; } /* ---------------------------------------------------------------------------- END_TSO_QUEUE @@ -544,7 +544,7 @@ INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_END_TSO_QUEUE,0,0,0,CONSTR_NOCAF,"END_TSO_QUEUE","END_TSO_QUEUE") -{ foreign "C" barf("END_TSO_QUEUE object entered!", 0) never returns; } +{ foreign "C" barf("END_TSO_QUEUE object entered!") never returns; } CLOSURE(stg_END_TSO_QUEUE_closure,stg_END_TSO_QUEUE); @@ -553,7 +553,7 @@ CLOSURE(stg_END_TSO_QUEUE_closure,stg_END_TSO_QUEUE); ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_GCD_CAF,0,0,0,CONSTR_NOCAF,"GCD_CAF","GCD_CAF") -{ foreign "C" barf("Evaluated a CAF that was GC'd!", 0) never returns; } +{ foreign "C" barf("Evaluated a CAF that was GC'd!") never returns; } /* ---------------------------------------------------------------------------- STM_AWOKEN @@ -563,7 +563,7 @@ INFO_TABLE_CONSTR(stg_GCD_CAF,0,0,0,CONSTR_NOCAF,"GCD_CAF","GCD_CAF") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_STM_AWOKEN,0,0,0,CONSTR_NOCAF,"STM_AWOKEN","STM_AWOKEN") -{ foreign "C" barf("STM_AWOKEN object entered!", 0) never returns; } +{ foreign "C" barf("STM_AWOKEN object entered!") never returns; } CLOSURE(stg_STM_AWOKEN_closure,stg_STM_AWOKEN); @@ -583,40 +583,40 @@ CLOSURE(stg_STM_AWOKEN_closure,stg_STM_AWOKEN); ------------------------------------------------------------------------- */ INFO_TABLE(stg_ARR_WORDS, 0, 0, ARR_WORDS, "ARR_WORDS", "ARR_WORDS") -{ foreign "C" barf("ARR_WORDS object entered!", 0) never returns; } +{ foreign "C" barf("ARR_WORDS object entered!") never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_CLEAN, 0, 0, MUT_ARR_PTRS_CLEAN, "MUT_ARR_PTRS_CLEAN", "MUT_ARR_PTRS_CLEAN") -{ foreign "C" barf("MUT_ARR_PTRS_CLEAN object entered!", 0) never returns; } +{ foreign "C" barf("MUT_ARR_PTRS_CLEAN object entered!") never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_DIRTY, 0, 0, MUT_ARR_PTRS_DIRTY, "MUT_ARR_PTRS_DIRTY", "MUT_ARR_PTRS_DIRTY") -{ foreign "C" barf("MUT_ARR_PTRS_DIRTY object entered!", 0) never returns; } +{ foreign "C" barf("MUT_ARR_PTRS_DIRTY object entered!") never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_FROZEN, 0, 0, MUT_ARR_PTRS_FROZEN, "MUT_ARR_PTRS_FROZEN", "MUT_ARR_PTRS_FROZEN") -{ foreign "C" barf("MUT_ARR_PTRS_FROZEN object entered!", 0) never returns; } +{ foreign "C" barf("MUT_ARR_PTRS_FROZEN object entered!") never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_FROZEN0, 0, 0, MUT_ARR_PTRS_FROZEN0, "MUT_ARR_PTRS_FROZEN0", "MUT_ARR_PTRS_FROZEN0") -{ foreign "C" barf("MUT_ARR_PTRS_FROZEN0 object entered!", 0) never returns; } +{ foreign "C" barf("MUT_ARR_PTRS_FROZEN0 object entered!") never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_CLEAN, 0, 0, SMALL_MUT_ARR_PTRS_CLEAN, "SMALL_MUT_ARR_PTRS_CLEAN", "SMALL_MUT_ARR_PTRS_CLEAN") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_CLEAN object entered!", 0) never returns; } +{ foreign "C" barf("SMALL_MUT_ARR_PTRS_CLEAN object entered!") never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_DIRTY, 0, 0, SMALL_MUT_ARR_PTRS_DIRTY, "SMALL_MUT_ARR_PTRS_DIRTY", "SMALL_MUT_ARR_PTRS_DIRTY") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_DIRTY object entered!", 0) never returns; } +{ foreign "C" barf("SMALL_MUT_ARR_PTRS_DIRTY object entered!") never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_FROZEN, 0, 0, SMALL_MUT_ARR_PTRS_FROZEN, "SMALL_MUT_ARR_PTRS_FROZEN", "SMALL_MUT_ARR_PTRS_FROZEN") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN object entered!", 0) never returns; } +{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN object entered!") never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_FROZEN0, 0, 0, SMALL_MUT_ARR_PTRS_FROZEN0, "SMALL_MUT_ARR_PTRS_FROZEN0", "SMALL_MUT_ARR_PTRS_FROZEN0") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN0 object entered!", 0) never returns; } +{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN0 object entered!") never returns; } /* ---------------------------------------------------------------------------- Mutable Variables ------------------------------------------------------------------------- */ INFO_TABLE(stg_MUT_VAR_CLEAN, 1, 0, MUT_VAR_CLEAN, "MUT_VAR_CLEAN", "MUT_VAR_CLEAN") -{ foreign "C" barf("MUT_VAR_CLEAN object entered!", 0) never returns; } +{ foreign "C" barf("MUT_VAR_CLEAN object entered!") never returns; } INFO_TABLE(stg_MUT_VAR_DIRTY, 1, 0, MUT_VAR_DIRTY, "MUT_VAR_DIRTY", "MUT_VAR_DIRTY") -{ foreign "C" barf("MUT_VAR_DIRTY object entered!", 0) never returns; } +{ foreign "C" barf("MUT_VAR_DIRTY object entered!") never returns; } /* ---------------------------------------------------------------------------- Dummy return closure @@ -638,7 +638,7 @@ CLOSURE(stg_dummy_ret_closure,stg_dummy_ret); ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE") -{ foreign "C" barf("MVAR_TSO_QUEUE object entered!", 0) never returns; } +{ foreign "C" barf("MVAR_TSO_QUEUE object entered!") never returns; } /* ---------------------------------------------------------------------------- COMPACT_NFDATA (a blob of data in NF with no outgoing pointers) @@ -651,11 +651,11 @@ INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE INFO_TABLE( stg_COMPACT_NFDATA_CLEAN, 0, 5, COMPACT_NFDATA, "COMPACT_NFDATA", "COMPACT_NFDATA") () -{ foreign "C" barf("COMPACT_NFDATA_CLEAN object entered!", 0) never returns; } +{ foreign "C" barf("COMPACT_NFDATA_CLEAN object entered!") never returns; } INFO_TABLE( stg_COMPACT_NFDATA_DIRTY, 0, 5, COMPACT_NFDATA, "COMPACT_NFDATA", "COMPACT_NFDATA") () -{ foreign "C" barf("COMPACT_NFDATA_DIRTY object entered!", 0) never returns; } +{ foreign "C" barf("COMPACT_NFDATA_DIRTY object entered!") never returns; } /* ---------------------------------------------------------------------------- CHARLIKE and INTLIKE closures. diff --git a/rts/StgStartup.cmm b/rts/StgStartup.cmm index 036e4eeff562..f67373031bfc 100644 --- a/rts/StgStartup.cmm +++ b/rts/StgStartup.cmm @@ -185,5 +185,5 @@ INFO_TABLE_RET(stg_forceIO, RET_SMALL, P_ info_ptr) /* Called when compiled with -falignment-sanitisation on alignment failure */ stg_badAlignment_entry { - foreign "C" barf("", 0); + foreign "C" barf(); } diff --git a/utils/genapply/Main.hs b/utils/genapply/Main.hs index df2fcfa2bd59..b30c9f8c46ac 100644 --- a/utils/genapply/Main.hs +++ b/utils/genapply/Main.hs @@ -789,7 +789,7 @@ genApply regstatus args = text "default: {", nest 4 ( - text "foreign \"C\" barf(\"" <> fun_ret_label <> text "\", 0) never returns;" + text "foreign \"C\" barf(\"" <> fun_ret_label <> text "\") never returns;" ), text "}" From 895006cb628bd1a2434749d7f056c901f9c76af1 Mon Sep 17 00:00:00 2001 From: Divam Date: Mon, 2 Jul 2018 17:08:52 +0900 Subject: [PATCH 4/4] Use wrapper around barf for cmm code. --- rts/Apply.cmm | 2 +- rts/Compact.cmm | 2 +- rts/PrimOps.cmm | 12 +++--- rts/RtsMessages.c | 20 ++++++++++ rts/StgMiscClosures.cmm | 88 ++++++++++++++++++++--------------------- rts/StgStartup.cmm | 2 +- utils/genapply/Main.hs | 2 +- 7 files changed, 74 insertions(+), 54 deletions(-) diff --git a/rts/Apply.cmm b/rts/Apply.cmm index 15d8250f5228..659b75ae6531 100644 --- a/rts/Apply.cmm +++ b/rts/Apply.cmm @@ -206,7 +206,7 @@ again: -------------------------------------------------------------------------- */ INFO_TABLE(stg_PAP,/*special layout*/0,0,PAP,"PAP","PAP") -{ ccall barf("PAP object entered!") never returns; } +{ ccall barf_cmm_wrapper("PAP object entered!") never returns; } stg_PAP_apply /* no args => explicit stack */ { diff --git a/rts/Compact.cmm b/rts/Compact.cmm index 719dac87f196..d6236f80a9e4 100644 --- a/rts/Compact.cmm +++ b/rts/Compact.cmm @@ -274,7 +274,7 @@ eval: goto constructor; }} - ccall barf("stg_compactWorkerzh"); + ccall barf_cmm_wrapper("stg_compactWorkerzh"); } // diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index e3f6e4cd19b5..6d386ed47db9 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -2105,7 +2105,7 @@ write_nptrs: stg_waitReadzh ( W_ fd ) { #if defined(THREADED_RTS) - ccall barf("waitRead# on threaded RTS") never returns; + ccall barf_cmm_wrapper("waitRead# on threaded RTS") never returns; #else ASSERT(StgTSO_why_blocked(CurrentTSO) == NotBlocked::I16); @@ -2121,7 +2121,7 @@ stg_waitReadzh ( W_ fd ) stg_waitWritezh ( W_ fd ) { #if defined(THREADED_RTS) - ccall barf("waitWrite# on threaded RTS") never returns; + ccall barf_cmm_wrapper("waitWrite# on threaded RTS") never returns; #else ASSERT(StgTSO_why_blocked(CurrentTSO) == NotBlocked::I16); @@ -2146,7 +2146,7 @@ stg_delayzh ( W_ us_delay ) #endif #if defined(THREADED_RTS) - ccall barf("delay# on threaded RTS") never returns; + ccall barf_cmm_wrapper("delay# on threaded RTS") never returns; #else ASSERT(StgTSO_why_blocked(CurrentTSO) == NotBlocked::I16); @@ -2208,7 +2208,7 @@ stg_asyncReadzh ( W_ fd, W_ is_sock, W_ len, W_ buf ) CInt reqID; #if defined(THREADED_RTS) - ccall barf("asyncRead# on threaded RTS") never returns; + ccall barf_cmm_wrapper("asyncRead# on threaded RTS") never returns; #else ASSERT(StgTSO_why_blocked(CurrentTSO) == NotBlocked::I16); @@ -2234,7 +2234,7 @@ stg_asyncWritezh ( W_ fd, W_ is_sock, W_ len, W_ buf ) CInt reqID; #if defined(THREADED_RTS) - ccall barf("asyncWrite# on threaded RTS") never returns; + ccall barf_cmm_wrapper("asyncWrite# on threaded RTS") never returns; #else ASSERT(StgTSO_why_blocked(CurrentTSO) == NotBlocked::I16); @@ -2260,7 +2260,7 @@ stg_asyncDoProczh ( W_ proc, W_ param ) CInt reqID; #if defined(THREADED_RTS) - ccall barf("asyncDoProc# on threaded RTS") never returns; + ccall barf_cmm_wrapper("asyncDoProc# on threaded RTS") never returns; #else ASSERT(StgTSO_why_blocked(CurrentTSO) == NotBlocked::I16); diff --git a/rts/RtsMessages.c b/rts/RtsMessages.c index d9767602428b..3d1f8eff98a4 100644 --- a/rts/RtsMessages.c +++ b/rts/RtsMessages.c @@ -49,6 +49,26 @@ barf(const char*s, ...) va_end(ap); } +// This wrapper is added to call barf from cmm code without varargs. +// This is a workaround to make clang generate correct calls in wasm +// target. Wasm does not directly support varargs, so Clang uses a +// different ABI for varargs calls than normal calls, which no other +// target does. +// +// https://bugs.llvm.org/show_bug.cgi?id=35385 +// +// TODO: Replace this by allowing Cmm code to indicate where varargs +// begin and calling `barf` correctly. +void +barf_cmm_wrapper(const char*s) + GNUC3_ATTRIBUTE(__noreturn__); + +void +barf_cmm_wrapper(const char*s) +{ + barf ("%s",s); +} + void vbarf(const char*s, va_list ap) { diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 9fd5fb8b88ab..26190a9dc21e 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -354,11 +354,11 @@ INFO_TABLE(__stg_EAGER_BLACKHOLE,1,0,BLACKHOLE,"BLACKHOLE","BLACKHOLE") } INFO_TABLE(stg_BLOCKING_QUEUE_CLEAN,4,0,BLOCKING_QUEUE,"BLOCKING_QUEUE","BLOCKING_QUEUE") -{ foreign "C" barf("BLOCKING_QUEUE_CLEAN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("BLOCKING_QUEUE_CLEAN object entered!") never returns; } INFO_TABLE(stg_BLOCKING_QUEUE_DIRTY,4,0,BLOCKING_QUEUE,"BLOCKING_QUEUE","BLOCKING_QUEUE") -{ foreign "C" barf("BLOCKING_QUEUE_DIRTY object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("BLOCKING_QUEUE_DIRTY object entered!") never returns; } /* ---------------------------------------------------------------------------- @@ -395,7 +395,7 @@ loop: } jump %ENTRY_CODE(info) (node); #else - ccall barf("WHITEHOLE object entered!") never returns; + ccall barf_cmm_wrapper("WHITEHOLE object entered!") never returns; #endif } @@ -406,10 +406,10 @@ loop: ------------------------------------------------------------------------- */ INFO_TABLE(stg_TSO, 0,0,TSO, "TSO", "TSO") -{ foreign "C" barf("TSO object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("TSO object entered!") never returns; } INFO_TABLE(stg_STACK, 0,0, STACK, "STACK", "STACK") -{ foreign "C" barf("STACK object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("STACK object entered!") never returns; } /* ---------------------------------------------------------------------------- Weak pointers @@ -420,7 +420,7 @@ INFO_TABLE(stg_STACK, 0,0, STACK, "STACK", "STACK") ------------------------------------------------------------------------- */ INFO_TABLE(stg_WEAK,1,4,WEAK,"WEAK","WEAK") -{ foreign "C" barf("WEAK object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("WEAK object entered!") never returns; } /* * It's important when turning an existing WEAK into a DEAD_WEAK @@ -429,7 +429,7 @@ INFO_TABLE(stg_WEAK,1,4,WEAK,"WEAK","WEAK") * DEAD_WEAK 5 non-pointer fields. */ INFO_TABLE_CONSTR(stg_DEAD_WEAK,0,5,0,CONSTR,"DEAD_WEAK","DEAD_WEAK") -{ foreign "C" barf("DEAD_WEAK object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("DEAD_WEAK object entered!") never returns; } /* ---------------------------------------------------------------------------- C finalizer lists @@ -438,7 +438,7 @@ INFO_TABLE_CONSTR(stg_DEAD_WEAK,0,5,0,CONSTR,"DEAD_WEAK","DEAD_WEAK") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_C_FINALIZER_LIST,1,4,0,CONSTR,"C_FINALIZER_LIST","C_FINALIZER_LIST") -{ foreign "C" barf("C_FINALIZER_LIST object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("C_FINALIZER_LIST object entered!") never returns; } /* ---------------------------------------------------------------------------- NO_FINALIZER @@ -448,7 +448,7 @@ INFO_TABLE_CONSTR(stg_C_FINALIZER_LIST,1,4,0,CONSTR,"C_FINALIZER_LIST","C_FINALI ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_NO_FINALIZER,0,0,0,CONSTR_NOCAF,"NO_FINALIZER","NO_FINALIZER") -{ foreign "C" barf("NO_FINALIZER object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("NO_FINALIZER object entered!") never returns; } CLOSURE(stg_NO_FINALIZER_closure,stg_NO_FINALIZER); @@ -457,7 +457,7 @@ CLOSURE(stg_NO_FINALIZER_closure,stg_NO_FINALIZER); ------------------------------------------------------------------------- */ INFO_TABLE(stg_STABLE_NAME,0,1,PRIM,"STABLE_NAME","STABLE_NAME") -{ foreign "C" barf("STABLE_NAME object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("STABLE_NAME object entered!") never returns; } /* ---------------------------------------------------------------------------- MVars @@ -467,47 +467,47 @@ INFO_TABLE(stg_STABLE_NAME,0,1,PRIM,"STABLE_NAME","STABLE_NAME") ------------------------------------------------------------------------- */ INFO_TABLE(stg_MVAR_CLEAN,3,0,MVAR_CLEAN,"MVAR","MVAR") -{ foreign "C" barf("MVAR object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MVAR object entered!") never returns; } INFO_TABLE(stg_MVAR_DIRTY,3,0,MVAR_DIRTY,"MVAR","MVAR") -{ foreign "C" barf("MVAR object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MVAR object entered!") never returns; } /* ----------------------------------------------------------------------------- STM -------------------------------------------------------------------------- */ INFO_TABLE(stg_TVAR_CLEAN, 2, 1, TVAR, "TVAR", "TVAR") -{ foreign "C" barf("TVAR_CLEAN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("TVAR_CLEAN object entered!") never returns; } INFO_TABLE(stg_TVAR_DIRTY, 2, 1, TVAR, "TVAR", "TVAR") -{ foreign "C" barf("TVAR_DIRTY object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("TVAR_DIRTY object entered!") never returns; } INFO_TABLE(stg_TVAR_WATCH_QUEUE, 3, 0, MUT_PRIM, "TVAR_WATCH_QUEUE", "TVAR_WATCH_QUEUE") -{ foreign "C" barf("TVAR_WATCH_QUEUE object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("TVAR_WATCH_QUEUE object entered!") never returns; } INFO_TABLE(stg_ATOMIC_INVARIANT, 2, 1, MUT_PRIM, "ATOMIC_INVARIANT", "ATOMIC_INVARIANT") -{ foreign "C" barf("ATOMIC_INVARIANT object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("ATOMIC_INVARIANT object entered!") never returns; } INFO_TABLE(stg_INVARIANT_CHECK_QUEUE, 3, 0, MUT_PRIM, "INVARIANT_CHECK_QUEUE", "INVARIANT_CHECK_QUEUE") -{ foreign "C" barf("INVARIANT_CHECK_QUEUE object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("INVARIANT_CHECK_QUEUE object entered!") never returns; } INFO_TABLE(stg_TREC_CHUNK, 0, 0, TREC_CHUNK, "TREC_CHUNK", "TREC_CHUNK") -{ foreign "C" barf("TREC_CHUNK object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("TREC_CHUNK object entered!") never returns; } INFO_TABLE(stg_TREC_HEADER, 3, 1, MUT_PRIM, "TREC_HEADER", "TREC_HEADER") -{ foreign "C" barf("TREC_HEADER object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("TREC_HEADER object entered!") never returns; } INFO_TABLE_CONSTR(stg_END_STM_WATCH_QUEUE,0,0,0,CONSTR_NOCAF,"END_STM_WATCH_QUEUE","END_STM_WATCH_QUEUE") -{ foreign "C" barf("END_STM_WATCH_QUEUE object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("END_STM_WATCH_QUEUE object entered!") never returns; } INFO_TABLE_CONSTR(stg_END_INVARIANT_CHECK_QUEUE,0,0,0,CONSTR_NOCAF,"END_INVARIANT_CHECK_QUEUE","END_INVARIANT_CHECK_QUEUE") -{ foreign "C" barf("END_INVARIANT_CHECK_QUEUE object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("END_INVARIANT_CHECK_QUEUE object entered!") never returns; } INFO_TABLE_CONSTR(stg_END_STM_CHUNK_LIST,0,0,0,CONSTR_NOCAF,"END_STM_CHUNK_LIST","END_STM_CHUNK_LIST") -{ foreign "C" barf("END_STM_CHUNK_LIST object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("END_STM_CHUNK_LIST object entered!") never returns; } INFO_TABLE_CONSTR(stg_NO_TREC,0,0,0,CONSTR_NOCAF,"NO_TREC","NO_TREC") -{ foreign "C" barf("NO_TREC object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("NO_TREC object entered!") never returns; } CLOSURE(stg_END_STM_WATCH_QUEUE_closure,stg_END_STM_WATCH_QUEUE); @@ -524,17 +524,17 @@ CLOSURE(stg_NO_TREC_closure,stg_NO_TREC); // PRIM rather than CONSTR, because PRIM objects cannot be duplicated by the GC. INFO_TABLE_CONSTR(stg_MSG_TRY_WAKEUP,2,0,0,PRIM,"MSG_TRY_WAKEUP","MSG_TRY_WAKEUP") -{ foreign "C" barf("MSG_TRY_WAKEUP object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MSG_TRY_WAKEUP object entered!") never returns; } INFO_TABLE_CONSTR(stg_MSG_THROWTO,4,0,0,PRIM,"MSG_THROWTO","MSG_THROWTO") -{ foreign "C" barf("MSG_THROWTO object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MSG_THROWTO object entered!") never returns; } INFO_TABLE_CONSTR(stg_MSG_BLACKHOLE,3,0,0,PRIM,"MSG_BLACKHOLE","MSG_BLACKHOLE") -{ foreign "C" barf("MSG_BLACKHOLE object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MSG_BLACKHOLE object entered!") never returns; } // used to overwrite a MSG_THROWTO when the message has been used/revoked INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") -{ foreign "C" barf("MSG_NULL object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MSG_NULL object entered!") never returns; } /* ---------------------------------------------------------------------------- END_TSO_QUEUE @@ -544,7 +544,7 @@ INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_END_TSO_QUEUE,0,0,0,CONSTR_NOCAF,"END_TSO_QUEUE","END_TSO_QUEUE") -{ foreign "C" barf("END_TSO_QUEUE object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("END_TSO_QUEUE object entered!") never returns; } CLOSURE(stg_END_TSO_QUEUE_closure,stg_END_TSO_QUEUE); @@ -553,7 +553,7 @@ CLOSURE(stg_END_TSO_QUEUE_closure,stg_END_TSO_QUEUE); ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_GCD_CAF,0,0,0,CONSTR_NOCAF,"GCD_CAF","GCD_CAF") -{ foreign "C" barf("Evaluated a CAF that was GC'd!") never returns; } +{ foreign "C" barf_cmm_wrapper("Evaluated a CAF that was GC'd!") never returns; } /* ---------------------------------------------------------------------------- STM_AWOKEN @@ -563,7 +563,7 @@ INFO_TABLE_CONSTR(stg_GCD_CAF,0,0,0,CONSTR_NOCAF,"GCD_CAF","GCD_CAF") ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_STM_AWOKEN,0,0,0,CONSTR_NOCAF,"STM_AWOKEN","STM_AWOKEN") -{ foreign "C" barf("STM_AWOKEN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("STM_AWOKEN object entered!") never returns; } CLOSURE(stg_STM_AWOKEN_closure,stg_STM_AWOKEN); @@ -583,40 +583,40 @@ CLOSURE(stg_STM_AWOKEN_closure,stg_STM_AWOKEN); ------------------------------------------------------------------------- */ INFO_TABLE(stg_ARR_WORDS, 0, 0, ARR_WORDS, "ARR_WORDS", "ARR_WORDS") -{ foreign "C" barf("ARR_WORDS object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("ARR_WORDS object entered!") never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_CLEAN, 0, 0, MUT_ARR_PTRS_CLEAN, "MUT_ARR_PTRS_CLEAN", "MUT_ARR_PTRS_CLEAN") -{ foreign "C" barf("MUT_ARR_PTRS_CLEAN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MUT_ARR_PTRS_CLEAN object entered!") never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_DIRTY, 0, 0, MUT_ARR_PTRS_DIRTY, "MUT_ARR_PTRS_DIRTY", "MUT_ARR_PTRS_DIRTY") -{ foreign "C" barf("MUT_ARR_PTRS_DIRTY object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MUT_ARR_PTRS_DIRTY object entered!") never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_FROZEN, 0, 0, MUT_ARR_PTRS_FROZEN, "MUT_ARR_PTRS_FROZEN", "MUT_ARR_PTRS_FROZEN") -{ foreign "C" barf("MUT_ARR_PTRS_FROZEN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MUT_ARR_PTRS_FROZEN object entered!") never returns; } INFO_TABLE(stg_MUT_ARR_PTRS_FROZEN0, 0, 0, MUT_ARR_PTRS_FROZEN0, "MUT_ARR_PTRS_FROZEN0", "MUT_ARR_PTRS_FROZEN0") -{ foreign "C" barf("MUT_ARR_PTRS_FROZEN0 object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MUT_ARR_PTRS_FROZEN0 object entered!") never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_CLEAN, 0, 0, SMALL_MUT_ARR_PTRS_CLEAN, "SMALL_MUT_ARR_PTRS_CLEAN", "SMALL_MUT_ARR_PTRS_CLEAN") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_CLEAN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("SMALL_MUT_ARR_PTRS_CLEAN object entered!") never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_DIRTY, 0, 0, SMALL_MUT_ARR_PTRS_DIRTY, "SMALL_MUT_ARR_PTRS_DIRTY", "SMALL_MUT_ARR_PTRS_DIRTY") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_DIRTY object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("SMALL_MUT_ARR_PTRS_DIRTY object entered!") never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_FROZEN, 0, 0, SMALL_MUT_ARR_PTRS_FROZEN, "SMALL_MUT_ARR_PTRS_FROZEN", "SMALL_MUT_ARR_PTRS_FROZEN") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("SMALL_MUT_ARR_PTRS_FROZEN object entered!") never returns; } INFO_TABLE(stg_SMALL_MUT_ARR_PTRS_FROZEN0, 0, 0, SMALL_MUT_ARR_PTRS_FROZEN0, "SMALL_MUT_ARR_PTRS_FROZEN0", "SMALL_MUT_ARR_PTRS_FROZEN0") -{ foreign "C" barf("SMALL_MUT_ARR_PTRS_FROZEN0 object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("SMALL_MUT_ARR_PTRS_FROZEN0 object entered!") never returns; } /* ---------------------------------------------------------------------------- Mutable Variables ------------------------------------------------------------------------- */ INFO_TABLE(stg_MUT_VAR_CLEAN, 1, 0, MUT_VAR_CLEAN, "MUT_VAR_CLEAN", "MUT_VAR_CLEAN") -{ foreign "C" barf("MUT_VAR_CLEAN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MUT_VAR_CLEAN object entered!") never returns; } INFO_TABLE(stg_MUT_VAR_DIRTY, 1, 0, MUT_VAR_DIRTY, "MUT_VAR_DIRTY", "MUT_VAR_DIRTY") -{ foreign "C" barf("MUT_VAR_DIRTY object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MUT_VAR_DIRTY object entered!") never returns; } /* ---------------------------------------------------------------------------- Dummy return closure @@ -638,7 +638,7 @@ CLOSURE(stg_dummy_ret_closure,stg_dummy_ret); ------------------------------------------------------------------------- */ INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE") -{ foreign "C" barf("MVAR_TSO_QUEUE object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("MVAR_TSO_QUEUE object entered!") never returns; } /* ---------------------------------------------------------------------------- COMPACT_NFDATA (a blob of data in NF with no outgoing pointers) @@ -651,11 +651,11 @@ INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE INFO_TABLE( stg_COMPACT_NFDATA_CLEAN, 0, 5, COMPACT_NFDATA, "COMPACT_NFDATA", "COMPACT_NFDATA") () -{ foreign "C" barf("COMPACT_NFDATA_CLEAN object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("COMPACT_NFDATA_CLEAN object entered!") never returns; } INFO_TABLE( stg_COMPACT_NFDATA_DIRTY, 0, 5, COMPACT_NFDATA, "COMPACT_NFDATA", "COMPACT_NFDATA") () -{ foreign "C" barf("COMPACT_NFDATA_DIRTY object entered!") never returns; } +{ foreign "C" barf_cmm_wrapper("COMPACT_NFDATA_DIRTY object entered!") never returns; } /* ---------------------------------------------------------------------------- CHARLIKE and INTLIKE closures. diff --git a/rts/StgStartup.cmm b/rts/StgStartup.cmm index f67373031bfc..2957ba8fa8a2 100644 --- a/rts/StgStartup.cmm +++ b/rts/StgStartup.cmm @@ -185,5 +185,5 @@ INFO_TABLE_RET(stg_forceIO, RET_SMALL, P_ info_ptr) /* Called when compiled with -falignment-sanitisation on alignment failure */ stg_badAlignment_entry { - foreign "C" barf(); + foreign "C" barf_cmm_wrapper(""); } diff --git a/utils/genapply/Main.hs b/utils/genapply/Main.hs index b30c9f8c46ac..6da7b5b02f95 100644 --- a/utils/genapply/Main.hs +++ b/utils/genapply/Main.hs @@ -789,7 +789,7 @@ genApply regstatus args = text "default: {", nest 4 ( - text "foreign \"C\" barf(\"" <> fun_ret_label <> text "\") never returns;" + text "foreign \"C\" barf_cmm_wrapper(\"" <> fun_ret_label <> text "\") never returns;" ), text "}"