[prev in list] [next in list] [prev in thread] [next in thread] 

List:       trousers-tech
Subject:    Re: [TrouSerS-tech] [PATCH] Support for compiling on OS X
From:       Mike Pontillo <MPontillo () mocana ! com>
Date:       2014-12-26 20:09:47
Message-ID: D0C1BC9E.58AEA%mpontillo () mocana ! com
[Download RAW message or body]

Hi Vicky,

   Yes, the 'clang' compiler used by OS X and iOS will fail to compile TrouSerS the \
way it is currently written.

   Compilers vary regarding how the 'inline' keyword is handled. See:

http://clang.llvm.org/compatibility.html#inline

   Given the fact that various combinations of 'inline' and other keywords result in \
undefined (or at least inconsistently-defined) behavior, I prefer to rely on behavior \
that will be consistent across all supported platforms. (That is, unless there is a \
compelling reason to enable platform-specific compiler optimizations, I would prefer \
to keep the code simple and clear.)

   In this case, the clang manual suggests using "static inline" as "usually the \
right solution". This is what you would use if you wanted a performance-critical \
section of code to be inlined for use within a single object file. However, since the \
functions were being used in multiple files, it was unlikely that 'inline' had much \
of an effect anyway. So I chose the 2nd option listed on that page in the clang \
manual, "Remove the inline keyword from this definition of add. The inline keyword is \
not required for a function to be inlined, nor does it guarantee that it will be. \
Some compilers ignore it completely. Clang treats it as a mild suggestion from the \
programmer."

Regards,
Mike


From: Hon Ching Lo <honclo2014@gmail.com<mailto:honclo2014@gmail.com>>
Date: Wednesday, December 24, 2014 at 9:02 PM
To: Mike Pontillo <mpontillo@mocana.com<mailto:mpontillo@mocana.com>>
Cc: "trousers-tech@lists.sourceforge.net<mailto:trousers-tech@lists.sourceforge.net>" \
                <trousers-tech@lists.sourceforge.net<mailto:trousers-tech@lists.sourceforge.net>>
                
Subject: Re: [TrouSerS-tech] [PATCH] Support for compiling on OS X

The patch looks good to me.  But there was one change that I've kept wondering:

> Removal of 'inline' inside 'extern' functions which were being made available to \
> other object files. (I believe this is undefined behavior; I'm not sure how the \
> compiler would inline these anyway; maybe it's a special feature?)

The code might have intended to inline some functions for other platforms aside from \
SOLARIS i.e. to take advantage of compiler optimization in those platforms.  Does \
anyone know the true motive behind?

Mike, if we didn't remove the inline keywords, would the code still work for IOS?  \
Just wondering.



Regards,
Vicky





On Wed, Oct 1, 2014 at 12:34 AM, Mike Pontillo \
<MPontillo@mocana.com<mailto:MPontillo@mocana.com>> wrote: Hi all,

   Even though we're using TrouSerS on Linux, it's convenient for
developers to
be able to compile it on OS X. (it would be nice for testing, in
conjunction
with the TPM emulator.)

   I went through and created a set of changes to allow this, including:

 * Not using GCC-specific LDFLAGS when compiling tcsd

 * Use of a public domain portable_endian.h to abstract the fact that you
   cannot #include <endian.h> on the Apple platform.

 * Addition of __APPLE__ to some places where __OpenBSD__ and __FreeBSD__
appear

 * Definition of HOST_NAME_MAX to avoid including bits/local_lim.h on
__APPLE__

   (I think this is a Linux-specific header)

 * Removal of 'inline' inside 'extern' functions which were being made
   available to other object files. (I believe this is undefined behavior;
I'm
   not sure how the compiler would inline these anyway; maybe it's a
special
   feature?)


 * Minor change to 'gitignore' to also ignore the 'compile' script that
gets
   generated.


   Also, I noticed some other changes that should be made which are not
included
in this patch:

 * bootstrap.sh should not use libtoolize
   (on OS X and Linux, I've used "autoreconf -f -i -v" successfully)

 * Fix compiler warnings regarding memset optimization
   (could have security considerations!)


   Please let me know if you're willing to accept this patch, and/or if it
should be improved upon first. I have attached the patch.

Thanks,
Mike Pontillo


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-tech mailing list
TrouSerS-tech@lists.sourceforge.net<mailto:TrouSerS-tech@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/trousers-tech


[Attachment #3 (text/html)]

<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; \
font-family: Calibri, sans-serif;"><div><div>Hi \
Vicky,</div><div><br></div><div>&nbsp; &nbsp;Yes, the 'clang' compiler used by OS X \
and iOS will fail to compile TrouSerS the way it is currently \
written.</div><div><br></div><div>&nbsp; &nbsp;Compilers vary regarding how the \
'inline' keyword is handled. See:</div><div><br></div><div><a \
href="http://clang.llvm.org/compatibility.html#inline">http://clang.llvm.org/compatibility.html#inline</a></div><div><br></div><div>&nbsp; \
&nbsp;Given the fact that various combinations of 'inline' and other keywords result \
in undefined (or at least inconsistently-defined) behavior, I prefer to rely on \
behavior that will be consistent across all supported platforms. (That is, unless \
there is a compelling reason to enable platform-specific compiler optimizations, I \
would prefer to keep the code simple and clear.)</div><div><br></div><div>&nbsp; \
&nbsp;In this case, the clang manual suggests using "static inline" as "usually the \
right solution". This is what you would use if you wanted a performance-critical \
section of code to be inlined for use within a single object file. However, since the \
functions were being used in multiple files, it was unlikely that 'inline' had much \
of an effect anyway. So I chose the 2nd option listed on that page in the clang \
manual, "Remove the inline keyword from this definition of add. The inline keyword is \
not required for a function to be inlined, nor does it guarantee that it will be. \
Some compilers ignore it completely. Clang treats it as a mild suggestion from the \
programmer."</div><div><br></div><div>Regards,</div><div>Mike</div><div><br></div></div><div><br></div><span \
id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:11pt; \
text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; \
PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt \
solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span \
style="font-weight:bold">From: </span> Hon Ching Lo &lt;<a \
href="mailto:honclo2014@gmail.com">honclo2014@gmail.com</a>&gt;<br><span \
style="font-weight:bold">Date: </span> Wednesday, December 24, 2014 at 9:02 \
PM<br><span style="font-weight:bold">To: </span> Mike Pontillo &lt;<a \
href="mailto:mpontillo@mocana.com">mpontillo@mocana.com</a>&gt;<br><span \
style="font-weight:bold">Cc: </span> "<a \
href="mailto:trousers-tech@lists.sourceforge.net">trousers-tech@lists.sourceforge.net</a>" \
&lt;<a href="mailto:trousers-tech@lists.sourceforge.net">trousers-tech@lists.sourceforge.net</a>&gt;<br><span \
style="font-weight:bold">Subject: </span> Re: [TrouSerS-tech] [PATCH] Support for \
compiling on OS X<br></div><div><br></div><div dir="ltr"><div><div><div></div>The \
patch looks good to me.&nbsp; But there was one change that I've kept wondering: \
<br><br>&gt;&nbsp; Removal of 'inline' inside 'extern' functions which were being \
made available to other object files. <br>&gt; (I believe this is undefined behavior; \
I'm not sure how the compiler would inline these anyway; <br>&gt; maybe it's a \
special feature?)<br><br>The code might have intended to inline some functions for \
other platforms aside from SOLARIS<br>i.e. to take advantage of compiler optimization \
in those platforms.&nbsp; Does anyone know the true <br>motive \
behind?<br><br></div><div>Mike, if we didn't remove the inline keywords, would the \
code still work for IOS?&nbsp; Just \
wondering.<br><br><br><br></div><div>Regards,<br></div><div>Vicky<br></div><div><br></div></div><div><div><div><br><br><br></div></div></div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 1, 2014 at 12:34 AM, \
Mike Pontillo <span dir="ltr">&lt;<a href="mailto:MPontillo@mocana.com" \
target="_blank">MPontillo@mocana.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Hi all,<br><br> &nbsp; &nbsp;Even though we're using TrouSerS \
on Linux, it's convenient for<br> developers to<br>
be able to compile it on OS X. (it would be nice for testing, in<br>
conjunction<br>
with the TPM emulator.)<br><br>
&nbsp; &nbsp;I went through and created a set of changes to allow this, \
including:<br><br> &nbsp;* Not using GCC-specific LDFLAGS when compiling tcsd<br><br>
&nbsp;* Use of a public domain portable_endian.h to abstract the fact that you<br>
&nbsp; &nbsp;cannot #include &lt;endian.h&gt; on the Apple platform.<br><br>
&nbsp;* Addition of __APPLE__ to some places where __OpenBSD__ and __FreeBSD__<br>
appear<br><br>
&nbsp;* Definition of HOST_NAME_MAX to avoid including bits/local_lim.h on<br>
__APPLE__<br><br>
&nbsp; &nbsp;(I think this is a Linux-specific header)<br><br>
&nbsp;* Removal of 'inline' inside 'extern' functions which were being made<br>
&nbsp; &nbsp;available to other object files. (I believe this is undefined \
behavior;<br> I'm<br>
&nbsp; &nbsp;not sure how the compiler would inline these anyway; maybe it's a<br>
special<br>
&nbsp; &nbsp;feature?)<br><br><br>
&nbsp;* Minor change to 'gitignore' to also ignore the 'compile' script that<br>
gets<br>
&nbsp; &nbsp;generated.<br><br><br>
&nbsp; &nbsp;Also, I noticed some other changes that should be made which are not<br>
included<br>
in this patch:<br><br>
&nbsp;* bootstrap.sh should not use libtoolize<br>
&nbsp; &nbsp;(on OS X and Linux, I've used "autoreconf -f -i -v" \
successfully)<br><br> &nbsp;* Fix compiler warnings regarding memset optimization<br>
&nbsp; &nbsp;(could have security considerations!)<br><br><br>
&nbsp; &nbsp;Please let me know if you're willing to accept this patch, and/or if \
it<br> should be improved upon first. I have attached the patch.<br><br>
Thanks,<br>
Mike Pontillo<br><br><br>------------------------------------------------------------------------------<br>
 Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer<br>
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports<br>
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper<br>
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer<br><a \
href="http://pubads.g.doubleclick.net/gampad/clk?id=154622311&amp;iu=/4140/ostg.clktrk" \
target="_blank">http://pubads.g.doubleclick.net/gampad/clk?id=154622311&amp;iu=/4140/ostg.clktrk</a><br>_______________________________________________<br>
 TrouSerS-tech mailing list<br><a \
href="mailto:TrouSerS-tech@lists.sourceforge.net">TrouSerS-tech@lists.sourceforge.net</a><br><a \
href="https://lists.sourceforge.net/lists/listinfo/trousers-tech" \
target="_blank">https://lists.sourceforge.net/lists/listinfo/trousers-tech</a><br><br></blockquote></div><br></div></span></body></html>



[Attachment #4 (--===============6323911157388582252==)]
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net

_______________________________________________
TrouSerS-tech mailing list
TrouSerS-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/trousers-tech


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic