diff --git a/compiler/GHC/CmmToAsm/PIC.hs b/compiler/GHC/CmmToAsm/PIC.hs index 5bda90ab455300789e8f4a16b74cd8a02006a22f..104d72d61eb106ef9e839287e53b5283ba145a95 100644 --- a/compiler/GHC/CmmToAsm/PIC.hs +++ b/compiler/GHC/CmmToAsm/PIC.hs @@ -137,6 +137,11 @@ cmmMakeDynamicReference config referenceKind lbl addImport symbolPtr return $ cmmLoadBWord platform (cmmMakePicReference config symbolPtr) + -- On wasm, always preserve the original CLabel, the backends + -- will handle dynamic references properly + AccessDirectly | ArchWasm32 <- platformArch platform -> + pure $ CmmLit $ CmmLabel lbl + AccessDirectly -> case referenceKind of -- for data, we might have to make some calculations: DataReference -> return $ cmmMakePicReference config lbl @@ -414,6 +419,11 @@ howToAccessLabel config _arch os _kind lbl then AccessViaSymbolPtr else AccessDirectly +-- On wasm, always keep the original CLabel and let the backend decide +-- how to handle dynamic references +howToAccessLabel _ ArchWasm32 _ _ _ + = AccessDirectly + -- all other platforms howToAccessLabel config _arch _os _kind _lbl | not (ncgPIC config)