1. 19 Nov, 2019 1 commit
  2. 02 Oct, 2019 1 commit
    • Egon Elbre's avatar
      cmd/cgo: optimize cgoCheckPointer call · e85ffec7
      Egon Elbre authored
      Currently cgoCheckPointer is only used with one optional argument.
      Using a slice for the optional arguments is quite expensive, hence
      replace it with a single interface{}. This results in ~30% improvement.
      
      When checking struct fields, they quite often end up being without
      pointers. Check this before calling cgoCheckPointer, which results in
      additional ~20% improvement.
      
      Inline some p == nil checks from cgoIsGoPointer which gives
      additional ~15% improvement.
      
      All of this translates to:
      
      name                             old time/op  new time/op  delta
      CgoCall/add-int-32               46.9ns ± 1%  46.6ns ± 1%   -0.75%  (p=0.000 n=18+20)
      CgoCall/one-pointer-32            143ns ± 1%    87ns ± 1%  -38.96%  (p=0.000 n=20+20)
      CgoCall/eight-pointers-32         767ns ± 0%   327ns ± 1%  -57.30%  (p=0.000 n=18+16)
      CgoCall/eight-pointers-nil-32     110ns ± 1%    89ns ± 2%  -19.10%  (p=0.000 n=19+19)
      CgoCall/eight-pointers-array-32  5.09µs ± 1%  3.56µs ± 2%  -30.09%  (p=0.000 n=19+19)
      CgoCall/eight-pointers-slice-32  3.92µs ± 0%  2.57µs ± 2%  -34.48%  (p=0.000 n=20+20)
      
      Change-Id: I2aa9f5ae8962a9a41a7fb1db0c300893109d0d75
      Reviewed-on: https://go-review.googlesource.com/c/go/+/198081
      
      
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      e85ffec7
  3. 05 Jul, 2019 1 commit
    • Austin Clements's avatar
      cmd/cgo: accept weak dynamic imports · a2fb5cd8
      Austin Clements authored
      cgo produces dynamic imports for Go binaries by scanning the dynamic
      imports table of a binary produced by the system C compiler and
      linker. Currently, since it uses elf.File.ImportedSymbols, it only
      reads global symbols. Unfortunately, recent versions of lld emit weak
      symbol imports for several pthread symbols, which means the cgo tool
      doesn't emit dynamic imports for them, which ultimately causes linking
      of cgo binaries to fail.
      
      Fix this by using elf.File.DynamicSymbols instead and filtering down
      to both global and weak symbols.
      
      Fixes #31912.
      
      Change-Id: If346a7eca6733e3bfa2cccf74a9cda02a3e81d38
      Reviewed-on: https://go-review.googlesource.com/c/go/+/184100
      
      
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      a2fb5cd8
  4. 05 Jun, 2019 1 commit
  5. 27 Mar, 2019 1 commit
    • Clément Chigot's avatar
      runtime: create library startup for aix/ppc64 · 38dc177d
      Clément Chigot authored
      As .init_array section aren't available on AIX, the Go runtime
      initialization is made with gcc constructor attribute.
      However, as cgo tool is building a binary in order to get imported
      C symbols, Go symbols imported for this initilization must be ignored.
      -Wl,-berok is mandatory otherwize ld will fail to create this binary,
      _rt0_aix_ppc64_lib and runtime_rt0_go aren't defined in runtime/cgo.
      These two symbols must also be ignored when creating _cgo_import.go.
      
      Change-Id: Icf2e0282f5b50de5fa82007439a428e6147efef1
      Reviewed-on: https://go-review.googlesource.com/c/go/+/169118
      
      
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      38dc177d
  6. 18 Mar, 2019 1 commit
  7. 08 Mar, 2019 2 commits
  8. 01 Feb, 2019 1 commit
  9. 30 Jan, 2019 1 commit
  10. 20 Jan, 2019 1 commit
  11. 10 Dec, 2018 1 commit
  12. 02 Dec, 2018 1 commit
  13. 01 Dec, 2018 1 commit
  14. 13 Nov, 2018 1 commit
  15. 09 Nov, 2018 1 commit
  16. 26 Oct, 2018 1 commit
  17. 22 Oct, 2018 1 commit
  18. 22 Aug, 2018 1 commit
  19. 31 Jul, 2018 1 commit
  20. 05 Jul, 2018 1 commit
  21. 02 Jul, 2018 1 commit
  22. 18 Jun, 2018 1 commit
  23. 01 Jun, 2018 1 commit
  24. 29 May, 2018 1 commit
  25. 25 Apr, 2018 1 commit
  26. 10 Jan, 2018 1 commit
  27. 14 Dec, 2017 1 commit
    • Ian Lance Taylor's avatar
      cmd/cgo: don't define intgo in export prologue · b944f91f
      Ian Lance Taylor authored
      The export prologue goes into the _cgo_export.h file, where it may be
      be #include'd by a .swig file. As SWIG defines its own type "intgo",
      the definition of "intgo" in the export prologue could conflict.
      Since we don't need to define "intgo" in the _cgo_export.h file, don't.
      
      Defining "intgo" in _cgo_export.h was new for this release, so this
      should not break any existing code.
      
      No test case as I can't quite bring myself to write a test that
      combines SWIG and cgo.
      
      Change-Id: I8073e8300a1860cecd5994b9ad07dd35a4298c89
      Reviewed-on: https://go-review.googlesource.com/83936
      
      
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      b944f91f
  28. 16 Nov, 2017 2 commits
    • Russ Cox's avatar
      cmd/go: make file:line for cgo files look like non-cgo files · 8c47aa15
      Russ Cox authored
      Passing the absolute path to cgo puts the absolute path in the
      generated file's //line directives, which then shows that path
      in the compiler output, which the go command can then
      make relative to the current directory, same as it does for
      other compiler output.
      
      Change-Id: Ia2064fea40078c46fd97e3a3b8c9fa1488f913e3
      Reviewed-on: https://go-review.googlesource.com/77154
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      8c47aa15
    • Russ Cox's avatar
      cmd/cgo: modify source as text, not as AST · 85c3ebf4
      Russ Cox authored
      Cgo has always operated by rewriting the AST and invoking go/printer.
      This CL converts it to use the AST to make decisions but then apply
      its edits directly to the underlying source text. This approach worked
      better in rsc.io/grind (used during the C to Go conversion) and also
      more recently in cmd/cover. It guarantees that all comments and
      line numbers are preserved exactly.
      
      This eliminates a lot of special concern about comments and
      problems with cgo not preserving meaningful comments.
      Combined with the CL changing cmd/cover to use the same
      approach, it means that the combination of applying cgo and
      applying cover still guarantees all comments and line numbers
      are preserved exactly.
      
      This sets us up to fix some cgo vs cover bugs by swapping
      the order in which they run during the go command.
      
      This also sets up #16623 a bit: the edit list being
      accumulated here is nearly exactly what you'd want
      to pass to the compiler for that issue.
      
      Change-Id: I7611815be22e7c5c0d4fc3fa11832c42b32c4eb3
      Reviewed-on: https://go-review.googlesource.com/77153
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      85c3ebf4
  29. 15 Nov, 2017 1 commit
  30. 11 Sep, 2017 1 commit
  31. 30 Aug, 2017 1 commit
    • Hiroshi Ioka's avatar
      cmd/cgo: support niladic function-like macros · 03876af9
      Hiroshi Ioka authored
      Currently, cgo supports only macros which can be reduced to constants
      or variables. The CL addresses remaining parts, macros which can be
      represented as niladic functions.
      
      The basic idea is simple:
        1. make a thin wrapper function per macros.
        2. replace macro expansions with function calls.
      
      Fixes #10715
      Fixes #18720
      
      Change-Id: I150b4fb48e9dc4cc34466ef6417c04ac93d4bc1a
      Reviewed-on: https://go-review.googlesource.com/43970
      
      
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      03876af9
  32. 16 Aug, 2017 1 commit
    • Michael Steinert's avatar
      cmd/cgo: unify cgo output for gc and gccgo · ee714947
      Michael Steinert authored
      When calling a Go function that returns multiple values from C, cgo
      generates a structure to hold the values. According to the documentation
      this structure is called `struct <function-name>_return`. When compiling
      for gccgo the generated structure name is `struct <function-name>_result`.
      This change updates the output for gccgo to match the documentation and
      output for gc.
      
      Fixes #20910
      
      Change-Id: Iaea8030a695a7aaf9d9f317447fc05615d8e4adc
      Reviewed-on: https://go-review.googlesource.com/49350
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      ee714947
  33. 08 Aug, 2017 1 commit
  34. 26 May, 2017 1 commit
  35. 22 Apr, 2017 1 commit
  36. 21 Apr, 2017 1 commit
  37. 07 Apr, 2017 1 commit
  38. 11 Nov, 2016 1 commit
    • Ian Lance Taylor's avatar
      cmd/cgo: don't ignore qualifiers, don't cast to void* · fb8c896a
      Ian Lance Taylor authored
      The cgo tool used to simply ignore C type qualifiers. To avoid problems
      when a C function expected a qualifier that was not present, cgo emitted
      a cast to void* around all pointer arguments. Unfortunately, that broke
      code that contains both a function declaration and a macro, when the
      macro required the argument to have the right type. To fix this problem,
      don't ignore qualifiers. They are easy enough to handle for the limited
      set of cases that matter for cgo, in which we don't care about array or
      function types.
      
      Fixes #17537.
      
      Change-Id: Ie2988d21db6ee016a3e99b07f53cfb0f1243a020
      Reviewed-on: https://go-review.googlesource.com/33097
      
      
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      fb8c896a