
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 448a55aa by maralorn at 2025-06-11T12:05:50-04:00 Add necessary flag for js linking - - - - - 459e8a42 by maralorn at 2025-06-11T12:05:50-04:00 Don’t use additional linker flags to detect presence of -fno-pie in configure.ac This mirrors the behavior of ghc-toolchain - - - - - 4c4c33d1 by Krzysztof Gogolewski at 2025-06-11T12:05:51-04:00 Fix EPT enforcement when mixing unboxed tuples and non-tuples The code was assuming that an alternative cannot be returning a normal datacon and an unboxed tuple at the same time. However, as seen in #26107, this can happen when using a GADT to refine the representation type. The solution is just to conservatively return TagDunno. - - - - - 6 changed files: - compiler/GHC/Stg/EnforceEpt/Types.hs - m4/fp_gcc_supports_no_pie.m4 - m4/fptools_set_c_ld_flags.m4 - + testsuite/tests/rep-poly/T26107.hs - testsuite/tests/rep-poly/all.T - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== compiler/GHC/Stg/EnforceEpt/Types.hs ===================================== @@ -39,8 +39,8 @@ type InferStgAlt = GenStgAlt 'InferTaggedBinders combineAltInfo :: TagInfo -> TagInfo -> TagInfo combineAltInfo TagDunno _ = TagDunno combineAltInfo _ TagDunno = TagDunno -combineAltInfo (TagTuple {}) TagProper = panic "Combining unboxed tuple with non-tuple result" -combineAltInfo TagProper (TagTuple {}) = panic "Combining unboxed tuple with non-tuple result" +combineAltInfo (TagTuple {}) TagProper = TagDunno -- This can happen with rep-polymorphic result, see #26107 +combineAltInfo TagProper (TagTuple {}) = TagDunno -- This can happen with rep-polymorphic result, see #26107 combineAltInfo TagProper TagProper = TagProper combineAltInfo (TagTuple is1) (TagTuple is2) = TagTuple (zipWithEqual combineAltInfo is1 is2) combineAltInfo (TagTagged) ti = ti ===================================== m4/fp_gcc_supports_no_pie.m4 ===================================== @@ -7,9 +7,9 @@ AC_DEFUN([FP_GCC_SUPPORTS_NO_PIE], AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING([whether CC supports -no-pie]) echo 'int main() { return 0; }' > conftest.c - "$CC" $CONF_GCC_CC_OPTS_STAGE2 -c conftest.c + "$CC" -c conftest.c # Some GCC versions only warn when passed an unrecognized flag. - if "$CC" $CONF_GCC_LINKER_OPTS_STAGE2 -no-pie -Werror conftest.o -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then + if "$CC" -no-pie -Werror conftest.o -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then CONF_GCC_SUPPORTS_NO_PIE=YES AC_MSG_RESULT([yes]) else ===================================== m4/fptools_set_c_ld_flags.m4 ===================================== @@ -109,6 +109,9 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS], $2="$$2 -mcmodel=medium" ;; + javascript*) + $3="$$3 -sEXPORTED_RUNTIME_METHODS=HEAP8,HEAPU8" + esac AC_MSG_RESULT([done]) ===================================== testsuite/tests/rep-poly/T26107.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE GADTs, UnboxedTuples #-} +module T26107 where + +import Data.Kind +import GHC.Exts + +type T :: TYPE rep -> Type +data T a where + A :: T Bool + B :: T (# #) + +f :: forall rep (a :: TYPE rep). T a -> a +f A = True +f B = (# #) ===================================== testsuite/tests/rep-poly/all.T ===================================== @@ -41,6 +41,7 @@ test('T23883a', normal, compile_fail, ['']) test('T23883b', normal, compile_fail, ['']) test('T23883c', normal, compile_fail, ['']) test('T23903', normal, compile_fail, ['']) +test('T26107', normal, compile, ['-O']) test('EtaExpandDataCon', normal, compile, ['-O']) test('EtaExpandStupid1', normal, compile, ['-Wno-deprecated-flags']) ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -324,6 +324,10 @@ addPlatformDepLinkFlags archOs cc ccLink0 = do ArchOS ArchPPC OSAIX -> -- We need `-D_THREAD_SAFE` to unlock the thread-local `errno`. return $ ccLink2 & over _prgFlags (++["-D_THREAD_SAFE","-Wl,-bnotextro"]) + ArchOS ArchJavaScript OSGhcjs -> + -- Since https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md#407---0... + -- the emcc linker does not export the HEAP8 memory view which is used by the js RTS by default anymore. + return $ ccLink2 & _prgFlags %++ "-sEXPORTED_RUNTIME_METHODS=HEAP8,HEAPU8" _ -> return ccLink2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a0a015f0d3ac08bfbd6e16dabc65c8... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a0a015f0d3ac08bfbd6e16dabc65c8... You're receiving this email because of your account on gitlab.haskell.org.