<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:30:12 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-32425] How to build MongoDB as a static executable</title>
                <link>https://jira.mongodb.org/browse/SERVER-32425</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I wanted to know if its possible to build &apos;mongod&apos; &lt;b&gt;statically&lt;/b&gt;. I am using following command and I see that build is success full but binary is still dynamically linked..&lt;/p&gt;

&lt;p&gt;scons --link-model=static  -j 44 CCFLAGS=&quot; -march=armv8-a+crc -static&quot; --disable-warnings-as-errors &lt;/p&gt;

&lt;p&gt;Any inputs on what compile options I should use to get statically linked executable?&lt;/p&gt;</description>
                <environment></environment>
        <key id="474782">SERVER-32425</key>
            <summary>How to build MongoDB as a static executable</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13202">Works as Designed</resolution>
                                        <assignee username="andrew.morrow@mongodb.com">Andrew Morrow</assignee>
                                    <reporter username="Arkeri">Praveen Arkeri</reporter>
                        <labels>
                    </labels>
                <created>Wed, 20 Dec 2017 18:04:39 +0000</created>
                <updated>Fri, 27 Oct 2023 13:54:03 +0000</updated>
                            <resolved>Fri, 12 Jan 2018 16:39:17 +0000</resolved>
                                                                    <component>Build</component>
                                        <votes>0</votes>
                                    <watches>8</watches>
                                                                                                                <comments>
                            <comment id="1772889" author="acm" created="Fri, 12 Jan 2018 16:39:17 +0000"  >&lt;p&gt;Hi -&lt;/p&gt;

&lt;p&gt;I&apos;m closing out this ticket since I haven&apos;t heard back from you. Feel free to update this ticket if you have any further questions.&lt;/p&gt;</comment>
                            <comment id="1765157" author="acm" created="Thu, 4 Jan 2018 17:11:41 +0000"  >&lt;p&gt;No idea about the relocation problems in libresolve.a: that looks like a platform issue that we can&apos;t really control. The warning about dlopen is pointing out that, as I stated above, dlopen is going to be weird in a fully static build. Perhaps it is not a problem unless you actually &lt;b&gt;call&lt;/b&gt; dlopen? If you want that warning to not break the build, you can build with &lt;tt&gt;--disable-warnings-as-errors&lt;/tt&gt;. You will still need to figure out the libresolv problem though.&lt;/p&gt;

&lt;p&gt;In general, static linking is deprecated on linux, and we make no effort to test or support fully static builds, so you are fighting an uphill battle here. You may well need to prune parts of the codebase out (shared_library_posix.cpp, whatever depends on libresolv) to make it work, sort of.&lt;/p&gt;</comment>
                            <comment id="1764749" author="arkeri" created="Thu, 4 Jan 2018 07:51:16 +0000"  >&lt;p&gt;@AndrewM&lt;br/&gt;
Motivation to have static binary is that we can use one binary to analyze performance on various platforms (silicon, instruction set simulators, cpu models, etc...). At times a window of performance critical code can be extracted and anlaysed for better understanding.&lt;/p&gt;

&lt;p&gt;I added dependency of library &apos;dl&apos; in top level Sconstruct file which resolved previous errors but few new ones have popped up now:&lt;br/&gt;
Change:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; if env.TargetOSIs(&apos;linux&apos;):&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;       env.Append( LIBS=[&apos;m&apos;,&quot;resolv&quot;, &quot;dl&quot;] )&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Errors:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;build/opt/mongo/platform/shared_library_posix.o: In function `mongo::SharedLibrary::create(boost::filesystem::path const&amp;amp;)&apos;:&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;src/mongo/platform/shared_library_posix.cpp:56: warning: Using &apos;dlopen&apos; in statically linked applications requires at runtime the shared libraries from the glibc version used for linking&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/5/../../../aarch64-linux-gnu/libresolv.a(res_query.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against external symbol `__stack_chk_guard@@GLIBC_2.17&apos; can not be used when making a shared object; recompile with -fPIC&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/5/../../../aarch64-linux-gnu/libresolv.a(res_query.o)(.text+0x58): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17&apos;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;/usr/bin/ld: final link failed: Bad value&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;collect2: error: ld returned 1 exit status&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</comment>
                            <comment id="1758219" author="acm" created="Thu, 21 Dec 2017 21:11:15 +0000"  >&lt;p&gt;Well, I think you fixed the first one by saying &lt;tt&gt;-static-libgcc&lt;/tt&gt;. However, the other issue looks more serious. Can you build with &lt;tt&gt;VERBOSE=1&lt;/tt&gt;, and see if the &lt;tt&gt;dl&lt;/tt&gt; library is on the link line for &lt;tt&gt;mongod&lt;/tt&gt;? If not, you could try adding &lt;tt&gt;LIBS=&quot;dl&quot;&lt;/tt&gt; to the SCons invocation. However, I&apos;m not entirely sure what it means to use the &lt;tt&gt;libdl&lt;/tt&gt; libraries from what is supposed to be a fully static build.&lt;/p&gt;

&lt;p&gt;It may be that this just isn&apos;t a supported configuration. So, let me ask: &lt;b&gt;why&lt;/b&gt; do you want to build a fully static version of &lt;tt&gt;mongod&lt;/tt&gt;? If you build it on a given linux distro, the dynamic build you get by default only links to system C ABI libraries, so should be moveable to any other ABI compatible version of that distro. Why is a static build needed?&lt;/p&gt;</comment>
                            <comment id="1757543" author="arkeri" created="Thu, 21 Dec 2017 04:22:43 +0000"  >&lt;p&gt;Hi Andrew,&lt;/p&gt;

&lt;p&gt;Thanks for your inputs, I removed -static flag from CCFLAGS and added it to LINKFLAGS but I see more errors. &lt;br/&gt;
Below you can see various options which I tried with LINKFLAGS and their respective error messages:&lt;/p&gt;

&lt;p&gt;LINKFLAGS=&quot; -Wl,-static&quot;&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;cannot find -lgcc_s&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;LINKFLAGS=&quot; -Wl,-static -static-libgcc&quot;&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;undefined reference to `dl_iterate_phdr&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;LINKFLAGS=&quot;-Wl,-static -static-libgcc -static-libstdc++&quot;&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;build/opt/mongo/util/stacktrace_posix.o: In function `mongo::printStackTrace(std::ostream&amp;amp;)&apos;:
	&lt;ul&gt;
		&lt;li&gt;mongo/src/mongo/util/stacktrace_posix.cpp:187: undefined reference to `dladdr&apos;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;build/opt/mongo/platform/shared_library_posix.o: In function `mongo::SharedLibrary::~SharedLibrary()&apos;:
	&lt;ul&gt;
		&lt;li&gt;mongo/src/mongo/platform/shared_library_posix.cpp:46: undefined reference to `dlclose&apos;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Am I missing any other flags?&lt;/p&gt;</comment>
                            <comment id="1757027" author="acm" created="Wed, 20 Dec 2017 18:12:32 +0000"  >&lt;p&gt;I&apos;m assuming that you are finding that the executable is still linked to system dynamic libraries? Given the &lt;tt&gt;-&lt;del&gt;link-model=static&lt;/tt&gt; I wouldn&apos;t expect to see any shared libraries of mongodb code involved. I think the issue may be that you are passing &lt;tt&gt;&lt;/del&gt;-static&lt;/tt&gt; to the compiler via &lt;tt&gt;CCFLAGS&lt;/tt&gt; but not to the linker, where it is actually required, so you end up depending on libc.so, for instance. Can you try removing &lt;tt&gt;-static&lt;/tt&gt; from &lt;tt&gt;CCFLAGS&lt;/tt&gt; and moving it to &lt;tt&gt;LINKFLAGS&lt;/tt&gt;, like &lt;tt&gt;scons --link-model=static -j 44 CCFLAGS=&quot; -march=armv8-a+crc&quot; --disable-warnings-as-errors LINKFLAGS=&quot;-Wl,-static&quot;&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;Please be aware that fully statically linked executables aren&apos;t necessarily supported - things like nsswitch and pam may not be fully supported by a link to the static C runtime.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 20 Dec 2017 18:12:32 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        6 years, 4 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            6 years, 4 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>andrew.morrow@mongodb.com</customfieldvalue>
            <customfieldvalue>Arkeri</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htmncn:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hte807:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htm9h3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>