-
Notifications
You must be signed in to change notification settings - Fork 279
implements: update modernc.org/cc pkg to v4 #1142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Any ideas/suggestions on what could be the reason for this error? |
I think you should go for cc.NewConfig(). Then there is a caveat in using cc.Parse() where it does not source anything by default. With that I think the following additional change should get us going.. index bc65f5a..c05c1de 100644
--- a/contrib/implements/internal/implements/cast.go
+++ b/contrib/implements/internal/implements/cast.go
@@ -2,6 +2,7 @@ package implements
import (
"fmt"
+ "runtime"
"strings"
"modernc.org/cc/v4"
@@ -66,16 +67,18 @@ func stubCFunctions(libname string) (CFunctions, error) {
if cstub == "" {
return nil, fmt.Errorf("no C stub available for '%s'", libname)
}
- conf := cc.Config{
- IncludePaths: []string{"@", "/usr/local/include", "/usr/include"},
- SysIncludePaths: []string{"@", "/usr/local/include", "/usr/include"},
+ conf, err := cc.NewConfig(runtime.GOOS, runtime.GOARCH, "-D_FILE_OFFSET_BITS=64")
+ if err != nil {
+ return nil, err
}
src := []cc.Source{
+ {Name: "predefined", Value: conf.Predefined},
+ {Name: "builtin", Value: cc.Builtin},
{Name: "typestubs", Value: typeStubs},
{Name: libname, Value: cstub},
}
- cAST, err := cc.Parse(&conf, src)
+ cAST, err := cc.Parse(conf, src)
if err != nil {
return nil, err
} |
8bc14b7 to
cc3a596
Compare
Thanks, that worked. |
|
What I would like to know is what's the motivation for this change? Is there something not working with the tool or is it just a desire to use a newer version of the library? |
Ah..my bad. |
Just a desire to use a newer version of the library as I was trying to fix old CVEs related to the previous version and I saw that the previous version is no longer maintained, so how about we upgrade to the latest version and be up-to-date with the latest releases. |
|
Sounds reasonable. Thanks for clarifying. |
cc3a596 to
95a4ba1
Compare
|
If everything looks good, can we get this merged? |
95a4ba1 to
b7bd72e
Compare
|
@anoopcs9 updated the code based on the discussion over slack, PTAL. |
anoopcs9
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still implements.txt (or implements.json) doesn't match. One difference is with librbd.h where the deprecated attribute is indirectly used with the help of another macro. Even otherwise somehow all standard system calls are listed which was not the case before. Unfortunately we need more investigation and changes.
The following additional check should get rid of those builtin functions: index c810a4c..89ccc00 100644
--- a/contrib/implements/internal/implements/cast.go
+++ b/contrib/implements/internal/implements/cast.go
@@ -3,6 +3,7 @@ package implements
import (
"fmt"
"runtime"
+ "strings"
"modernc.org/cc/v4"
)
@@ -62,6 +63,7 @@ func stubCFunctions(libname string) (CFunctions, error) {
for _, n := range cAST.Scope.Nodes[i] {
if n, ok := n.(*cc.Declarator); ok &&
!n.IsTypename() &&
+ !strings.Contains(n.String(), "<builtin>") &&
n.DirectDeclarator != nil &&
(n.DirectDeclarator.Case == cc.DirectDeclaratorFuncParam ||
n.DirectDeclarator.Case == cc.DirectDeclaratorFuncIdent) { |
Thanks, in the meantime I got us a fix for the librbd issue where the |
Cool, with that and #1145 I could match the contents for implements.txt using the following change (there's a variation from my previous suggestion in #1142 (comment)): index fe75794..0681213 100644
--- a/contrib/implements/internal/implements/cast.go
+++ b/contrib/implements/internal/implements/cast.go
@@ -3,6 +3,7 @@ package implements
import (
"fmt"
"runtime"
+ "strings"
"modernc.org/cc/v4"
)
@@ -63,14 +64,15 @@ func stubCFunctions(libname string) (CFunctions, error) {
for _, n := range cAST.Scope.Nodes[i] {
if n, ok := n.(*cc.Declarator); ok &&
!n.IsTypename() &&
+ strings.HasPrefix(n.Name(), funcPrefix[libname]) &&
n.DirectDeclarator != nil &&
(n.DirectDeclarator.Case == cc.DirectDeclaratorFuncParam ||
n.DirectDeclarator.Case == cc.DirectDeclaratorFuncIdent) {
name := n.Name()
if _, exists := cfMap[name]; !exists {
isDeprecated := false
- if n.Type().Attributes().IsAttrSet("deprecated") {
- isDeprecated = true
+ if attrs := n.Type().Attributes(); attrs != nil {
+ isDeprecated = attrs.IsAttrSet("deprecated")
}
cf := CFunction{
Name: name, |
Ack, then I will wait for your PR to be merged and the new release for the cc pkg to be available and then rebase the PR. |
Let's wait for the next release. |
b7bd72e to
8caafb9
Compare
|
@anoopcs9 updated and rebased the PR with the newer version of pkg which contains the fix, PTAL. |
anoopcs9
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks for the perseverance 😊.
|
@ansiwen can you PTAL and add your review/comments? |
ansiwen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, (although I didn't dive deep into the changes of the v4 API now). Thanks a lot @Nikhil-Ladha and @anoopcs9 for the hard work on this!
|
@Mergifyio rebase |
update modernc.org/cc pkg to v4 and make required api changes to the cast script for metadata generation Signed-off-by: Nikhil-Ladha <nikhilladha1999@gmail.com>
✅ Branch has been successfully rebased |
8caafb9 to
78fd58f
Compare
Update modernc.org/cc pkg to v4 and make required api changes to the cast script for metadata generation
Checklist
//go:build ceph_previewmake api-updateto record new APIsNew or infrequent contributors may want to review the go-ceph Developer's Guide including the section on how we track API Status and the API Stability Plan.
The go-ceph project uses mergify. View the mergify command guide for information on how to interact with mergify. Add a comment with
@Mergifyiorebaseto rebase your PR when github indicates that the PR is out of date with the base branch.