Bug 101766 - Microblaze gcc misses symver but __has_attribute(symver) returns true
Summary: Microblaze gcc misses symver but __has_attribute(symver) returns true
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 10.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 102110 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-08-03 20:03 UTC by Giulio Benetti
Modified: 2023-03-13 00:37 UTC (History)
2 users (show)

See Also:
Host:
Target: Microblaze
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
add macro to microblaze.h (355 bytes, patch)
2023-03-13 00:36 UTC, Vincent Fazio
Details | Diff
partial patch for microblaze migration to elfos.h (4.28 KB, patch)
2023-03-13 00:37 UTC, Vincent Fazio
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Giulio Benetti 2021-08-03 20:03:32 UTC
Microblaze gcc can't use .symver attribute leading to:
error: symver is only supported on ELF platforms

This is a simple test-case(taken from libfuse3) that reproduce the problem:
'''
# if !__has_attribute (symver)
# error symver attribute not supported
# endif
#else
#error __has_attribute not defined, assume we do not have symver
#endif

__attribute__ ((symver ("fuse_new@FUSE_3.0")))
void func1(void)
{

}

int main(void) {
    return 0;
}

'''
The problem is the discrepancy I've found between __has_attribute(symver)
that return true, while in gcc/gcc/config.gcc 'elfos.h' is not listed under
Microblaze cases. Trying adding elfos.h to it leads to other linker problems
and this makes me think that Microblaze doesn't actually support __ELF__(symver).
So I thought to build gcc using --disable-symvers explictly until a fix is found, but that doesn't either work.

Can you please give help?

Thanks a lot!
Comment 1 Andrew Pinski 2021-08-03 20:16:54 UTC
__has_attribute is broken for many attributes.  If GCC supports them in a generic way but does not really support them, __has_attribute still returns true.
Comment 2 Giulio Benetti 2021-08-03 21:30:04 UTC
Ah ok, so the workaround is to check with a little build test, right?
Comment 3 Giulio Benetti 2021-08-03 23:02:49 UTC
I've done this:
https://github.com/libfuse/libfuse/pull/620/commits/3aba09a5c56e017746c5c1652dbc845f4db7374a

and works fine. It doesn't seem to have pitfalls.
Comment 4 Andrew Pinski 2021-08-27 21:55:46 UTC
*** Bug 102110 has been marked as a duplicate of this bug. ***
Comment 5 Vincent Fazio 2023-03-13 00:35:34 UTC
There's a mail discussion about this topic

https://gcc.gnu.org/pipermail/gcc/2023-March/240834.html

The "easy" route is to just add the proper macro to config/microblaze/microblaze.h

The more correct, but more arduous, route is "porting" microblaze to correctly use the elfos.h header and provide the proper overrides in a separate header.

I've tested the former with zero issues and tested a version of the latter and was able to compile both a kernel and ramfs and successfully boot but doubt all cases are accounted for. attaching patches for posterity
Comment 6 Vincent Fazio 2023-03-13 00:36:37 UTC
Created attachment 54645 [details]
add macro to microblaze.h
Comment 7 Vincent Fazio 2023-03-13 00:37:11 UTC
Created attachment 54646 [details]
partial patch for microblaze migration to elfos.h