<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
img {
max-width: 100%;
height: auto;
}
p.details {
font-style:italic;
color:#777
}
.footer p {
font-size:small;
color:#777
}
pre.commit-message {
white-space: pre-wrap;
}
.file-stats a {
text-decoration: none;
}
.file-stats .new-file {
color: #090;
}
.file-stats .deleted-file {
color: #B00;
}
</style>
<body>
<div class='content'>
<h3>Amar Takhar pushed to branch master at <a href="https://gitlab.com/NTPsec/ntpsec">NTPsec / ntpsec</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/7f142ff8f35da2cef5a62205f3456090ac1fb3c8">7f142ff8</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-10T11:12:56Z</i>
</div>
<pre class='commit-message'>Add support for detecting specific compilers.
This will be used in both the build and testsuite. It can be used in-source as
well to avoid any quirks.
It defines COMPILER_X eg COMPILER_CLANG, COMPILER_GCC or COMPILER_ICC for now.</pre>
</li>
</ul>
<h4>2 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
<span class='new-file'>
+
pylib/compiler.py
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
pylib/configure.py
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/7f142ff8f35da2cef5a62205f3456090ac1fb3c8#diff-0'>
<strong>
pylib/compiler.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- /dev/null
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/compiler.py
</span><span style="color: #aaaaaa">@@ -0,0 +1,61 @@
</span><span style="color: #000000;background-color: #ddffdd">+# Some compilers decide they like to mimic GCC as close as possible.
+# Unfortunately this usually does not apply to #pragma's. There can also be
+# quirks that need to be dodged specific to a compiler.
+#
+# There are also differences when it comes to coverage and profiling between
+# compilers. We'll want to support all to see how the source reacts under
+# different compilers and architectures.
+#
+# This file exist as the definitive way to check what compiler we're working
+# under it defines COMPILER_X in both config.h and the build system.
+
+COMPILER_FRAG = """
+#include <stdio.h>
+
+int main(void) {
+#ifdef __clang__
+ printf("1");
+#elif __INTEL_COMPILER
+ printf("2");
+#elif __GNUC__
+ printf("3");
+#else
+ printf("255");
+#endif
+ return 0;
+}
+"""
+
+
+def check_compiler(ctx):
+
+ defines = {
+ 1: ("COMPILER_CLANG", "clang"),
+ 2: ("COMPILER_ICC", "ICC"),
+ 3: ("COMPILER_GCC", "GCC"),
+ 255: ("COMPILER_GCC", "Unknown (Defaulting to GCC)"),
+ }
+
+ ret = ctx.check_cc(
+ fragment = COMPILER_FRAG,
+ msg = "Checking compiler",
+ define_name = "COMPILER_INT",
+ quote = False,
+ execute = True,
+ define_ret = True,
+ mandatory = True
+ )
+
+ compiler_int = int(ctx.get_define("COMPILER_INT"))
+
+ ctx.undefine("COMPILER_INT") # Not needed.
+
+ define, name = defines[compiler_int]
+
+ ctx.start_msg("Compiler found")
+
+ ctx.define(define, 1) # config.h
+ ctx.env[define] = True # Build system.
+
+ ctx.end_msg(name)
+
</span></code></pre>
<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/7f142ff8f35da2cef5a62205f3456090ac1fb3c8#diff-1'>
<strong>
pylib/configure.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/pylib/configure.py
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/configure.py
</span><span style="color: #aaaaaa">@@ -8,6 +8,13 @@ def cmd_configure(ctx):
</span> srcnode = ctx.srcnode.abspath()
bldnode = ctx.bldnode.abspath()
<span style="color: #000000;background-color: #ddffdd">+ ctx.load('compiler_c')
+ ctx.load('bison')
+
+
+ from compiler import check_compiler
+ check_compiler(ctx)
+
</span> from check_type import check_type
from check_sizeof import check_sizeof
from check_structfield import check_structfield
<span style="color: #aaaaaa">@@ -23,9 +30,6 @@ def cmd_configure(ctx):
</span> return
<span style="color: #000000;background-color: #ffdddd">- ctx.load('compiler_c')
- ctx.load('bison')
-
</span> # This needs to be at the top since it modifies CC and AR
if ctx.options.enable_fortify:
from check_fortify import check_fortify
</code></pre>
<br>
</li>
</div>
<div class='footer' style='margin-top: 10px;'>
<p>
—
<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/7f142ff8f35da2cef5a62205f3456090ac1fb3c8">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.com/NTPsec/ntpsec/commit/7f142ff8f35da2cef5a62205f3456090ac1fb3c8"}}</script>
</p>
</div>
</body>
</html>