Skip to content
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

@link("lib") is ignored with top-level @extern methods #3603

Closed
lolgab opened this issue Nov 13, 2023 · 2 comments · Fixed by #3604
Closed

@link("lib") is ignored with top-level @extern methods #3603

lolgab opened this issue Nov 13, 2023 · 2 comments · Fixed by #3604

Comments

@lolgab
Copy link
Contributor

lolgab commented Nov 13, 2023

While

@extern
@link("unit")
object externs {
  def nxt_unit_init(init: Ptr[Byte]): Ptr[Byte] = extern
}

does add -lunit to the linking options, the equivalent top-level definition doesn't add linking options:

@extern
@link("unit")
def nxt_unit_init(init: Ptr[Byte]): Ptr[Byte] = extern
@armanbilge
Copy link
Member

armanbilge commented Nov 13, 2023

I think @define will have the same issue, I noticed this when working on it. The reachability analysis currently only considers these annotation/attributes for modules (i.e. objects), not for methods. But it can be fixed :)

def reachModule(defn: Defn.Module): Unit = {
val Defn.Module(attrs, name, parent, traits) = defn
implicit val pos: nir.Position = defn.pos
newInfo(
new Class(
attrs,
name,
parent.map(classInfoOrObject),
traits.flatMap(traitInfo),
isModule = true
)
)
reachAttrs(attrs)
}

@WojciechMazur
Copy link
Contributor

Thank you for report and the reproducer. I think we were not checking method annotations in the compiler plugin. The fix is on the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants