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

Can't find cc1.exe.a for plugin #230

Open
coco875 opened this issue Jul 12, 2024 · 3 comments
Open

Can't find cc1.exe.a for plugin #230

coco875 opened this issue Jul 12, 2024 · 3 comments

Comments

@coco875
Copy link

coco875 commented Jul 12, 2024

gcc give the abilities to make some plugin but from https://gcc.gnu.org/onlinedocs/gccint/Plugins-building.html it's say for windows it require add cc1.exe.a who are in plugin directory at the same level that all include but can't find it and without it I get:

$ g++ -shared -IC:/Users/perei/Documents/GitHub/C-hook-static/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/plugin/include -fPIC -fno-rtti -O2 -Wl,--export-all-symbols plugin1.c -o plugin.so
C:/Users/username/Documents/GitHub/C-hook-static/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\tmp\ccoCJLgn.o:plugin1.c:(.text+0x57): undefined reference to `register_callback'
C:/Users/username/Documents/GitHub/C-hook-static/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\tmp\ccoCJLgn.o:plugin1.c:(.text+0x8): undefined reference to `register_attribute(attribute_spec const*)'
@coco875
Copy link
Author

coco875 commented Jul 12, 2024

just in case the code I try to compile:

#include "gcc-plugin.h"
#include "plugin-version.h"
#include "tree.h"

#ifdef _WIN32
__declspec(dllexport)
#endif
int plugin_is_GPL_compatible;

/* Attribute handler callback */
static tree handle_hook_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs) {
    printf("hello hook!\n");
    return NULL_TREE;
}

/* Attribute definition */
static struct attribute_spec hook_attr =
    { "hook", 1, 1, false,  false, false, false, handle_hook_attribute, NULL };

/* Plugin callback called during attribute registration.
Registered with register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL)
*/
static void register_attributes(void *event_data, void *data) {
    register_attribute(&hook_attr);
}

#ifdef _WIN32
__declspec(dllexport)
#endif
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) {
    const char *plugin_name = plugin_info->base_name;
    printf("Hello, World!\n");
    register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
    return 0;
}
```

@coco875
Copy link
Author

coco875 commented Jul 12, 2024

I succeed to found it in https://packages.msys2.org/package/mingw-w64-x86_64-gcc but not in mingw distribute or w64devkit and in winlibs there is header but not cc1plus.exe.a or cc1.exe.a

@brechtsanders
Copy link
Owner

I do build GCC with the --enable-plugin flag, but no .exe.a files are generated.

But I don't know why that's the case.

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

No branches or pull requests

2 participants