<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style='--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;'>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>

<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>

<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";'>
<div class="content">

<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.com/Doekin">Doekin</a> created a merge request: <a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/1947">!1947</a>
</p>
<div class="branch">
Project:Branches: Doekin/gnutls:clean-fips to gnutls/gnutls:master
</div>
<div class="author">
Author: Doekin
</div>
<div class="assignee">
Assignees: 
</div>
<div class="reviewer">
Reviewers: 
</div>
<div class="approvers">

</div>
<div class="md gl-mt-5" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word; margin-top: 1rem;">
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">This PR fixes linking failures that occur when building shared <code style='font-size: 90%; color: #18171d; word-wrap: break-word; border-radius: .25rem; background-color: #ececef; margin-top: 0; font-weight: inherit; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>gnutls-openssl</code> with Clang at optimization level -O0, where an undefined reference to <code style='font-size: 90%; color: #18171d; word-wrap: break-word; border-radius: .25rem; background-color: #ececef; font-weight: inherit; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_lib_state</code> error would appear (issue <a href="https://gitlab.com/gnutls/gnutls/-/issues/1690" data-reference-type="issue" data-original="#1690" data-link="false" data-link-reference="false" data-issue="165185321" data-project="179611" data-iid="1690" data-namespace-path="gnutls/gnutls" data-project-path="gnutls/gnutls" data-issue-type="issue" data-container="body" data-placement="top" title="Fails to link shared `gnutls-openssl` due to `undefined reference to '_gnutls_lib_state'` when compiled with Clang and no optimization" class="gfm gfm-issue">#1690</a>).</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The root cause is a duplicate <code style='font-size: 90%; color: #18171d; word-wrap: break-word; border-radius: .25rem; background-color: #ececef; margin-top: 0; font-weight: inherit; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_switch_lib_state</code> declaration that overrides the preceding <code style='font-size: 90%; color: #18171d; word-wrap: break-word; border-radius: .25rem; background-color: #ececef; font-weight: inherit; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>inline static</code> definition. When compiling with Clang -O0, this causes the symbol to be treated as an external reference rather than being inlined.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Reproduction case:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre data-canonical-lang="c" class="code highlight js-syntax-highlight language-c" v-pre="true" style='display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; border-radius: .25rem; background-color: inherit; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="c" style="margin-top: 0;"><span class="k" style="margin-top: 0;">extern</span> <span class="kt">int</span> <span class="n">_state</span><span class="p">;</span></span>
<span id="LC2" class="line" lang="c"><span class="kr" style="margin-top: 0;">inline</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">set_state</span><span class="p">(</span><span class="kt">int</span> <span class="n">state</span><span class="p">)</span></span>
<span id="LC3" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC4" class="line" lang="c">    <span class="n" style="margin-top: 0;">_state</span> <span class="o">=</span> <span class="n">state</span><span class="p">;</span></span>
<span id="LC5" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span>
<span id="LC6" class="line" lang="c"><span class="cm" style="margin-top: 0;">/* void set_state(int state); */</span>  <span class="cm">/* removing this avoids the issue */</span></span>
<span id="LC7" class="line" lang="c"><span class="kt" style="margin-top: 0;">void</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">void</span><span class="p">){}</span></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Compilation behavior:</p>
<ol dir="auto" style="text-align: initial; margin: 0; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Without the duplicate declaration:
<ul style="margin: 0; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Both Clang and GCC produce no undefined symbols</li>
</ul>
</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">With the duplicate declaration:
<ul style="margin: 0; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Clang produces <code style='font-size: 90%; color: #18171d; word-wrap: break-word; border-radius: .25rem; background-color: #ececef; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>U _state</code> in symbol table</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">GCC still produces no undefined symbols</li>
</ul>
</li>
</ol>
</div>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/1947">view it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.com">gitlab.com</a>. <a href="https://gitlab.com/-/sent_notifications/931d1a56a43f17bc500ea6b740a21406/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.com/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.com/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.com/gnutls/gnutls/-/merge_requests/1947"}}</script>


</p>
</div>
</body>
</html>