You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metron.apache.org by nickwallen <gi...@git.apache.org> on 2017/11/27 20:44:28 UTC

[GitHub] metron pull request #849: METRON-1320 Add C++11 Compliance Check to platform...

GitHub user nickwallen opened a pull request:

    https://github.com/apache/metron/pull/849

    METRON-1320 Add C++11 Compliance Check to platform-info

    Some of the module dependencies for the Management and Alerts UI must be built natively on the host.  This requires a C/C++ compiler.  In addition, some of the dependencies require a C++11 compliant compiler.  This is causing problems for users who attempt to build Metron on a system with an older version of GCC, like CentOS 6.
    
    Not having a C++11 compliant compiler can cause some non-obvious error messages when the build fails.  This adds a version check for GCC and also a C++11 compliance check.  The compiler itself must be on the user's PATH, which is what the Node modules also require.
    
    If the compiler is C++11 compliant, you will see the following.
    ```
    --
    g++
    g++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    --
    Compiler is C++11 compliant
    ```
    
    If the compiler is NOT C++11 compliant, you will see the following.
    ```
    --
    g++
    g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    --
    cc1plus: error: unrecognized command line option "-std=c++11"
    Warning: Compiler is NOT C++11 compliant
    ```
    
    This was tested manually on Mac OS X, CentOS 6, CentOS 7, and Ubuntu Trusty 64.
    
    
    ## Pull Request Checklist
    
    - [ ] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel). 
    - [ ] Does your PR title start with METRON-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
    - [ ] Have you included steps to reproduce the behavior or problem that is being changed or addressed?
    - [ ] Have you included steps or a guide to how the change may be verified and tested manually?
    - [ ] Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
    - [ ] Have you written or updated unit tests and or integration tests to verify your changes?
    - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [ ] Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nickwallen/metron METRON-1320

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metron/pull/849.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #849
    
----
commit 4ca17d5780729a61615e7ee6bc86e6ddf86c339e
Author: Nick Allen <ni...@nickallen.org>
Date:   2017-11-27T20:29:38Z

    METRON-1320 Cannot perform a bare-metal installation

----


---

[GitHub] metron issue #849: METRON-1334 Add C++11 Compliance Check to 'platform-info....

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/849
  
    I think that is valid


---

[GitHub] metron issue #849: METRON-1334 Add C++11 Compliance Check to 'platform-info....

Posted by JonZeolla <gi...@git.apache.org>.
Github user JonZeolla commented on the issue:

    https://github.com/apache/metron/pull/849
  
    Instead of trying to explaining my position, I threw together a quick PR to illustrate my thoughts.  Feel free to take another approach.  I tested it with `g++` configured, unconfigured, and not in my PATH on macOS, as well as on a CentOS 7 with and without gcc installed, and an Ubuntu 14.04 box with an old version of gcc installed (not C++11 compliant).  All worked as expected.


---

[GitHub] metron pull request #849: METRON-1334 Add C++11 Compliance Check to 'platfor...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/849#discussion_r153322627
  
    --- Diff: metron-deployment/scripts/platform-info.sh ---
    @@ -73,6 +73,30 @@ echo "--"
     echo "npm"
     npm --version
     
    +# C++ compiler
    +echo "--"
    +echo "g++"
    +g++ --version
    +
    +# C++11 compliant compiler
    +echo "--"
    +OBJFILE=/tmp/test
    +CPPFILE=/tmp/test.cpp
    +cat > $CPPFILE <<- EOM
    +#include <iostream>
    +using namespace std;
    +int main() {
    +    cout << "Hello World!" << endl;
    +    return 0;
    +}
    +EOM
    +g++ -std=c++11 $CPPFILE -o $OBJFILE
    +if [ $? -eq 0 ]; then
    +    echo "Compiler is C++11 compliant"
    +else
    +    echo "Warning: Compiler is NOT C++11 compliant"
    +fi
    +rm -f $CPPFILE $OBJFILE
     
    --- End diff --
    
    A standard way in the language is to check for the value of __cplusplus
    
    201402L  is CPP 14
    201103L is CPP 11
    
    I don't have a preference, just throwing this out there.


---

[GitHub] metron issue #849: METRON-1334 Add C++11 Compliance Check to 'platform-info....

Posted by JonZeolla <gi...@git.apache.org>.
Github user JonZeolla commented on the issue:

    https://github.com/apache/metron/pull/849
  
    +1 great stuff @nickwallen 


---

[GitHub] metron pull request #849: METRON-1334 Add C++11 Compliance Check to 'platfor...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/849#discussion_r153322856
  
    --- Diff: metron-deployment/scripts/platform-info.sh ---
    @@ -73,6 +73,30 @@ echo "--"
     echo "npm"
     npm --version
     
    +# C++ compiler
    +echo "--"
    +echo "g++"
    +g++ --version
    +
    +# C++11 compliant compiler
    +echo "--"
    +OBJFILE=/tmp/test
    +CPPFILE=/tmp/test.cpp
    +cat > $CPPFILE <<- EOM
    +#include <iostream>
    +using namespace std;
    +int main() {
    +    cout << "Hello World!" << endl;
    +    return 0;
    +}
    +EOM
    +g++ -std=c++11 $CPPFILE -o $OBJFILE
    +if [ $? -eq 0 ]; then
    +    echo "Compiler is C++11 compliant"
    +else
    +    echo "Warning: Compiler is NOT C++11 compliant"
    +fi
    +rm -f $CPPFILE $OBJFILE
     
    --- End diff --
    
    Do we have to account for platform_info on a non-dev machine?  If there is no g++ at all?


---

[GitHub] metron pull request #849: METRON-1334 Add C++11 Compliance Check to 'platfor...

Posted by nickwallen <gi...@git.apache.org>.
Github user nickwallen commented on a diff in the pull request:

    https://github.com/apache/metron/pull/849#discussion_r153325047
  
    --- Diff: metron-deployment/scripts/platform-info.sh ---
    @@ -73,6 +73,30 @@ echo "--"
     echo "npm"
     npm --version
     
    +# C++ compiler
    +echo "--"
    +echo "g++"
    +g++ --version
    +
    +# C++11 compliant compiler
    +echo "--"
    +OBJFILE=/tmp/test
    +CPPFILE=/tmp/test.cpp
    +cat > $CPPFILE <<- EOM
    +#include <iostream>
    +using namespace std;
    +int main() {
    +    cout << "Hello World!" << endl;
    +    return 0;
    +}
    +EOM
    +g++ -std=c++11 $CPPFILE -o $OBJFILE
    +if [ $? -eq 0 ]; then
    +    echo "Compiler is C++11 compliant"
    +else
    +    echo "Warning: Compiler is NOT C++11 compliant"
    +fi
    +rm -f $CPPFILE $OBJFILE
     
    --- End diff --
    
    > A standard way in the language is to check for the value of __cplusplus
    
    Thanks, I saw that.  I didn't think it was worth the trouble.  IMHO


---

[GitHub] metron pull request #849: METRON-1334 Add C++11 Compliance Check to 'platfor...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/849#discussion_r153328847
  
    --- Diff: metron-deployment/scripts/platform-info.sh ---
    @@ -73,6 +73,30 @@ echo "--"
     echo "npm"
     npm --version
     
    +# C++ compiler
    +echo "--"
    +echo "g++"
    +g++ --version
    +
    +# C++11 compliant compiler
    +echo "--"
    +OBJFILE=/tmp/test
    +CPPFILE=/tmp/test.cpp
    +cat > $CPPFILE <<- EOM
    +#include <iostream>
    +using namespace std;
    +int main() {
    +    cout << "Hello World!" << endl;
    +    return 0;
    +}
    +EOM
    +g++ -std=c++11 $CPPFILE -o $OBJFILE
    +if [ $? -eq 0 ]; then
    +    echo "Compiler is C++11 compliant"
    +else
    +    echo "Warning: Compiler is NOT C++11 compliant"
    +fi
    +rm -f $CPPFILE $OBJFILE
     
    --- End diff --
    
    i agree about it not being worth the trouble.
    
    as far as g++, I would expect us to check (pseudo)
    
    if c++ in path then
        build test program
    else
        echo No Cpp, you are in trouble!
    fi
    
    Maybe I'm mis-reading this, if there is no cpp, it will still try to build etc won't it?
    



---

[GitHub] metron issue #849: METRON-1334 Add C++11 Compliance Check to 'platform-info....

Posted by nickwallen <gi...@git.apache.org>.
Github user nickwallen commented on the issue:

    https://github.com/apache/metron/pull/849
  
    > Is this the expected output?
    
    I agree with @ottobackwards . That looks like what I would expect to see.  
    
    @JonZeolla I assume since you asked, it is not what you would expect.  What would prefer to see here?


---

[GitHub] metron pull request #849: METRON-1334 Add C++11 Compliance Check to 'platfor...

Posted by nickwallen <gi...@git.apache.org>.
Github user nickwallen commented on a diff in the pull request:

    https://github.com/apache/metron/pull/849#discussion_r153336117
  
    --- Diff: metron-deployment/scripts/platform-info.sh ---
    @@ -73,6 +73,30 @@ echo "--"
     echo "npm"
     npm --version
     
    +# C++ compiler
    +echo "--"
    +echo "g++"
    +g++ --version
    +
    +# C++11 compliant compiler
    +echo "--"
    +OBJFILE=/tmp/test
    +CPPFILE=/tmp/test.cpp
    +cat > $CPPFILE <<- EOM
    +#include <iostream>
    +using namespace std;
    +int main() {
    +    cout << "Hello World!" << endl;
    +    return 0;
    +}
    +EOM
    +g++ -std=c++11 $CPPFILE -o $OBJFILE
    +if [ $? -eq 0 ]; then
    +    echo "Compiler is C++11 compliant"
    +else
    +    echo "Warning: Compiler is NOT C++11 compliant"
    +fi
    +rm -f $CPPFILE $OBJFILE
     
    --- End diff --
    
    No worries.  Glad to have a second set of eyes on it.


---

[GitHub] metron pull request #849: METRON-1334 Add C++11 Compliance Check to 'platfor...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/849#discussion_r153334325
  
    --- Diff: metron-deployment/scripts/platform-info.sh ---
    @@ -73,6 +73,30 @@ echo "--"
     echo "npm"
     npm --version
     
    +# C++ compiler
    +echo "--"
    +echo "g++"
    +g++ --version
    +
    +# C++11 compliant compiler
    +echo "--"
    +OBJFILE=/tmp/test
    +CPPFILE=/tmp/test.cpp
    +cat > $CPPFILE <<- EOM
    +#include <iostream>
    +using namespace std;
    +int main() {
    +    cout << "Hello World!" << endl;
    +    return 0;
    +}
    +EOM
    +g++ -std=c++11 $CPPFILE -o $OBJFILE
    +if [ $? -eq 0 ]; then
    +    echo "Compiler is C++11 compliant"
    +else
    +    echo "Warning: Compiler is NOT C++11 compliant"
    +fi
    +rm -f $CPPFILE $OBJFILE
     
    --- End diff --
    
    OK, I ran it, I did mis-understand.  sorry.



---

[GitHub] metron pull request #849: METRON-1334 Add C++11 Compliance Check to 'platfor...

Posted by nickwallen <gi...@git.apache.org>.
Github user nickwallen commented on a diff in the pull request:

    https://github.com/apache/metron/pull/849#discussion_r153324714
  
    --- Diff: metron-deployment/scripts/platform-info.sh ---
    @@ -73,6 +73,30 @@ echo "--"
     echo "npm"
     npm --version
     
    +# C++ compiler
    +echo "--"
    +echo "g++"
    +g++ --version
    +
    +# C++11 compliant compiler
    +echo "--"
    +OBJFILE=/tmp/test
    +CPPFILE=/tmp/test.cpp
    +cat > $CPPFILE <<- EOM
    +#include <iostream>
    +using namespace std;
    +int main() {
    +    cout << "Hello World!" << endl;
    +    return 0;
    +}
    +EOM
    +g++ -std=c++11 $CPPFILE -o $OBJFILE
    +if [ $? -eq 0 ]; then
    +    echo "Compiler is C++11 compliant"
    +else
    +    echo "Warning: Compiler is NOT C++11 compliant"
    +fi
    +rm -f $CPPFILE $OBJFILE
     
    --- End diff --
    
    > Do we have to account for platform_info on a non-dev machine? If there is no g++ at all?
    
    The platform-info script is there to tell us whether a machine can be used to deploy metron.  Right now, you have to build Metron to deploy it, so the script checks all dev dependencies.
    
    If g++ is not in the path, then the script will tell us that.  And it would carry on its merry way.  That's the behavior that I would expect.
    
    Maybe I am not following you. Can you describe the scenario you are thinking of more?


---

[GitHub] metron issue #849: METRON-1334 Add C++11 Compliance Check to 'platform-info....

Posted by JonZeolla <gi...@git.apache.org>.
Github user JonZeolla commented on the issue:

    https://github.com/apache/metron/pull/849
  
    Ran on a purposefully misconfigured macOS system.  Is this the expected output?
    ```
    --
    g++
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    --
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    Warning: Compiler is NOT C++11 compliant
    --
    ```


---

[GitHub] metron issue #849: METRON-1334 Add C++11 Compliance Check to 'platform-info....

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/849
  
    +1, Tested on OSX and on centos 6 with and without compliant g++ installed
    Thanks Nick!


---

[GitHub] metron pull request #849: METRON-1334 Add C++11 Compliance Check to 'platfor...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/metron/pull/849


---