FAQ
Hello everyone,

I'm wondering, if someone could help me debug why I'm getting compile
warnings with gcc.

is it due to a header file change in the FreeBSD source tree?
or, Maybe gcc 4.7 more sensitive to warnings?

I'm fully aware this is only a warning, and doesn't hurt anything, but I'd
like to know why it's happening, this doesn't happen on a 10.x version of
FreeBSD



Here is some simple Go code:


package main

/*

#include <stdlib.h>

*/
import "C"

import (
         "fmt"
         "strings"
         "syscall"
)

// Returns system Hostname
func getSystemHostname() string {
         val, _ := syscall.Sysctl("kern.hostname")
         return val
}

func main() {
         fmt.Printf("%s\n", getSystemHostname())
}



/*
Generates the following warning:

sfourman@Sam ~/go/src/freebsd % go build tf.go
# command-line-arguments
cc: warning: argument unused during compilation: '-pthread'

*/



The system is running HEAD (the edge of the FreeBSD source tree)

uname -a
FreeBSD Sam 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r271218: Sun Sep 7
04:45:38 CDT 2014 sfourman@Sam:/usr/obj/usr/src/sys/GENERIC amd64


gcc --version
gcc47 (FreeBSD Ports Collection) 4.7.4
Copyright (C) 2012 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.



Thanks in advance,
--

Sam Fourman Jr.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Ian Lance Taylor at Sep 8, 2014 at 3:05 pm

    On Mon, Sep 8, 2014 at 2:51 AM, Sam Fourman Jr. wrote:
    I'm wondering, if someone could help me debug why I'm getting compile
    warnings with gcc.

    is it due to a header file change in the FreeBSD source tree?
    No.

    or, Maybe gcc 4.7 more sensitive to warnings?
    Possibly. Although as far as I know GCC does not generate this
    particular warning.

    sfourman@Sam ~/go/src/freebsd % go build tf.go
    # command-line-arguments
    cc: warning: argument unused during compilation: '-pthread'
    Note that this warning is from cc, not gcc. What does "cc --version"
    print?

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sam Fourman Jr. at Sep 8, 2014 at 3:11 pm

    sfourman@Sam ~/go/src/freebsd % go build tf.go
    # command-line-arguments
    cc: warning: argument unused during compilation: '-pthread'
    Note that this warning is from cc, not gcc. What does "cc --version"
    print?

    cc --version
    FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
    Target: x86_64-unknown-freebsd11.0
    Thread model: posix


    --

    Sam Fourman Jr.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Ian Lance Taylor at Sep 8, 2014 at 4:57 pm

    On Mon, Sep 8, 2014 at 8:11 AM, Sam Fourman Jr. wrote:
    sfourman@Sam ~/go/src/freebsd % go build tf.go
    # command-line-arguments
    cc: warning: argument unused during compilation: '-pthread'
    Note that this warning is from cc, not gcc. What does "cc --version"
    print?

    cc --version
    FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
    Target: x86_64-unknown-freebsd11.0
    Thread model: posix
    OK, so the error is coming from clang, not gcc.

    Do you have the CC or GCC environment variables set? What does "go
    env" print for CC?

    Currently if the compiler command includes the string "clang" cgo will
    add -Qunused-arguments which will presumably disable this warning.
    But we don't seem to have a good mechanism for doing this if the cgo
    tool defaults to "cc" and "cc" is "clang".

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sam Fourman Jr. at Sep 8, 2014 at 7:15 pm

    On Mon, Sep 8, 2014 at 11:57 AM, Ian Lance Taylor wrote:
    On Mon, Sep 8, 2014 at 8:11 AM, Sam Fourman Jr. wrote:

    sfourman@Sam ~/go/src/freebsd % go build tf.go
    # command-line-arguments
    cc: warning: argument unused during compilation: '-pthread'
    Note that this warning is from cc, not gcc. What does "cc --version"
    print?

    cc --version
    FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
    Target: x86_64-unknown-freebsd11.0
    Thread model: posix
    OK, so the error is coming from clang, not gcc.

    Do you have the CC or GCC environment variables set? What does "go
    env" print for CC?
    sfourman@Sam ~/go/src/freebsd % go env
    GOARCH="amd64"
    GOBIN=""
    GOCHAR="6"
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="freebsd"
    GOOS="freebsd"
    GOPATH="/home/sfourman/go"
    GORACE=""
    GOROOT="/usr/local/go"
    GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
    CC="cc"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
    CXX="g++"
    CGO_ENABLED="1"



    Currently if the compiler command includes the string "clang" cgo will
    add -Qunused-arguments which will presumably disable this warning.
    But we don't seem to have a good mechanism for doing this if the cgo
    tool defaults to "cc" and "cc" is "clang".
    Yes in at least FreeBSD "cc" is clang, and it seems the other BSD's are
    moving in this direction as well.

    Could go use the output of cc --version to decide what flags to throw cc?

    Ian
    >



    --

    Sam Fourman Jr.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Ian Lance Taylor at Sep 8, 2014 at 7:39 pm

    On Mon, Sep 8, 2014 at 12:15 PM, Sam Fourman Jr. wrote:
    Could go use the output of cc --version to decide what flags to throw cc?
    In principle, sure. I'm not sure whether we should aim to do that for
    each execution of go or cgo, or whether we should do it in cmd/dist.

    Anyhow, please open an issue. Thanks.

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 8, '14 at 9:51a
activeSep 8, '14 at 7:39p
posts6
users2
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase