<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>232938</bug_id>
          
          <creation_ts>2021-11-10 03:29:43 -0800</creation_ts>
          <short_desc>[CMake] Reduce memory usage when not using the Gold linker</short_desc>
          <delta_ts>2022-02-16 14:00:23 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alexander Kanavin">alex.kanavin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annulen</cc>
    
    <cc>aperez</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>ryuan.choi</cc>
    
    <cc>sergio</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1813536</commentid>
    <comment_count>0</comment_count>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2021-11-10 03:29:43 -0800</bug_when>
    <thetext>Reduce memory usage when not using the Gold linker</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1813537</commentid>
    <comment_count>1</comment_count>
      <attachid>443794</attachid>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2021-11-10 03:30:04 -0800</bug_when>
    <thetext>Created attachment 443794
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1815889</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-11-17 03:30:23 -0800</bug_when>
    <thetext>&lt;rdar://problem/85497847&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1842475</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-02-16 13:03:22 -0800</bug_when>
    <thetext>This probably made sense to do at the time you wrote this patch, but unluckily for you Adrian refactored all of this code a week or two ago. He will probably want to review this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1842507</commentid>
    <comment_count>4</comment_count>
      <attachid>443794</attachid>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-02-16 13:50:48 -0800</bug_when>
    <thetext>Comment on attachment 443794
Patch

In general I do not like this patch because it&apos;s going to make the build
process slower for everybody, even for people with plenty of memory to
spare which do not really need to use this linker option. From the ld man
page:

  “This option reduces memory requirements at ld runtime, at the expense
   of linking speed.”

Making linking slower is something that we definitely *not* want in general,
because who spends more time building (and linking) WebKit are developers.
We would rather optimize by default to have shorter edit-compile-test cycles.
Coincidentally, that&apos;s the reason why developer builds use LLD if available:
it gets the job done faster.

If you have some *particular* setup in which this is needed, you can specify
the option as part of the LDFLAGS environment variable, and CMake will apply
it for you:

   % LDFLAGS=&quot;-Wl,--reduce-memory-overheads&quot; cmake ...

or, if you are using the “build-webkit” script for development:

   % LDFLAGS=&quot;-Wl,--reduce-memory-overheads&quot; Tools/Scripts/build-webkit ...

If there is some reason why this is not an option for you, please do explain
and we can reconsider adding something to the WebKit build system, and make it
opt-in — but I would prefer to avoid hardcoding options in our build system
for one-off configurations which typically can be done as suggested above :)


View in context: https://bugs.webkit.org/attachment.cgi?id=443794&amp;action=review

&gt; Source/cmake/OptionsCommon.cmake:107
&gt; +    set(CMAKE_SHARED_LINKER_FLAGS &quot;${CMAKE_EXE_LINKER_FLAGS} -Wl,--reduce-memory-overheads&quot;)

This has changed quite a bit, so currently you should check the LD_VARIANT
variable to only add these options when using the BFD linker. Like this:

  if (LD_VARIANT STREQUAL BFD)
      # Do things.
  endif ()

This is missing adding the option to CMAKE_MODULE_LINKER_FLAGS, too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1842510</commentid>
    <comment_count>5</comment_count>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2022-02-16 13:52:58 -0800</bug_when>
    <thetext>No problem. This one wasn&apos;t actually written by me, I only collected downstream yocto patches, and submitted them all.

I&apos;ll drop this on the next version update, and ask the author to upstream first, if they still care.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1842512</commentid>
    <comment_count>6</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-02-16 13:54:13 -0800</bug_when>
    <thetext>Ah, one last comment: if you are short on memory in the machine where
you need to build WebKit, you may want to try LLD, which in general is
the fastest linker *and* it uses less memory than Gold. Currently the
Gold linker is abandonware and is mostly unmaintained.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1842513</commentid>
    <comment_count>7</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-02-16 13:57:39 -0800</bug_when>
    <thetext>(In reply to Alexander Kanavin from comment #5)
&gt; No problem. This one wasn&apos;t actually written by me, I only collected
&gt; downstream yocto patches, and submitted them all.
&gt; 
&gt; I&apos;ll drop this on the next version update, and ask the author to upstream
&gt; first, if they still care.

Sounds good. As said, if there is a good reason for a similar patch
we can reconsider; but it seemed rather specific to a particular build
environment.

I definitely don&apos;t want to demotivate anybody to bring downstream patches
into the WebKit repository — on the contrary, we are willing to try to
help including patches that help packagers, usually those are generic
(or can be made generic), to benefit everybody :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1842515</commentid>
    <comment_count>8</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-02-16 13:59:03 -0800</bug_when>
    <thetext>I&apos;ll close this for now, but again I&apos;ll say it&apos;s fine to reopen it
if needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1842516</commentid>
    <comment_count>9</comment_count>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2022-02-16 14:00:23 -0800</bug_when>
    <thetext>Just for reference, this is where it was added:
https://git.yoctoproject.org/poky/commit/?h=master-next&amp;id=c61948e9b80c664ea298b9f9e4daf3ccec145449

There&apos;s a link to a debian ticket too in there.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>443794</attachid>
            <date>2021-11-10 03:30:04 -0800</date>
            <delta_ts>2022-02-16 13:50:48 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-232938-20211110123003.patch</filename>
            <type>text/plain</type>
            <size>1368</size>
            <attacher name="Alexander Kanavin">alex.kanavin</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjg1NTcwCmRpZmYgLS1naXQgYS9Tb3VyY2UvY21ha2UvT3B0
aW9uc0NvbW1vbi5jbWFrZSBiL1NvdXJjZS9jbWFrZS9PcHRpb25zQ29tbW9uLmNtYWtlCmluZGV4
IDZjNDBmMjM4YWI3N2RjZGJhZDE1NzA0N2QxODY0ZjU0NTlmNjIwM2MuLjcxOGQzMGE0ODA1Y2Nj
YzUzM2FiZTU4ZGI2YTdhMzIxYjQ0Zjk0NTAgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9jbWFrZS9PcHRp
b25zQ29tbW9uLmNtYWtlCisrKyBiL1NvdXJjZS9jbWFrZS9PcHRpb25zQ29tbW9uLmNtYWtlCkBA
IC0xMDEsNiArMTAxLDExIEBAIG9wdGlvbihHQ0NfT0ZGTElORUFTTV9TT1VSQ0VfTUFQCiAgICR7
R0NDX09GRkxJTkV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Ag
ICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0yMzI5MzgKKworICAg
ICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICAqIFNvdXJjZS9jbWFr
ZS9PcHRpb25zQ29tbW9uLmNtYWtlOgorCiAyMDIxLTExLTA5ICBKIFBhc2NvZSAgPGpfcGFzY29l
QGFwcGxlLmNvbT4KIAogICAgICAgICBBZGQgal9wYXNjb2UgdG8gY29udHJpYnV0b3JzLmpzb24K
</data>
<flag name="review"
          id="468596"
          type_id="1"
          status="-"
          setter="aperez"
    />
    <flag name="commit-queue"
          id="468623"
          type_id="3"
          status="-"
          setter="ews-feeder"
    />
          </attachment>
      

    </bug>

</bugzilla>