[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

dong jianqiang via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 21 23:36:10 PST 2023


dongjianqiang2 wrote:

> > > > @MaskRay the reason for adding this option is that gcc supports it. please refer to [godbolt.org/z/54sE6zTa1](https://godbolt.org/z/54sE6zTa1)
> > > 
> > > 
> > > This doesn't answer my question. GCC has a lot of options that Clang doesn't support. An option supported by GCC does not mean that Clang needs to support it. This option has perfect replacement, which makes it even questionable (since to the best of my knowledge `-export-dynamic` driver option is not used) See my previous comment:
> > > > GCC's default spec file for Linux does not say how -export-dynamic translates to ld -export-dynamic.
> > > > I think ld --export-dynamic is exclusively caused by -Wl,--export-dynamic or -rdynamic.
> > > > Do you have any example of gcc -export-dynamic uses?
> > 
> > 
> > This is historically undocumented option. and yes, it can be repalced by -rdynamic. See [PR47390](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47390). The purpose of this pull request is to ensure consistency between the two compilers. If you think it's unnecessary to support it, I'm fine with it. : )
> 
> Thank you for digging this up. So `-export-dynamic` is the only special `-exxx` option GCC supports. Except this gawk issue (2011) which likely gets fixed long ago, `gcc -export-dynamic` seems to have no use. This doesn't justify driver adding an option (that we know is not a good thing) special case.
> 
> Note that `clang -e xxx` or `clang -exxx` did not work before 2020-07, so even all `-exxx` `-e xxx` all probably rarely used. We should consider [#72804 (comment)](https://github.com/llvm/llvm-project/pull/72804#issuecomment-1820321163)

Currently, we are switching to the llvm compiler in embedded system. In some scenarios, the -e option is used to specify the program entry address.  gcc supportes both `-e xxx` and `-exxx`, so it may not be a good idea to support '-e xxx' only. So far, I've only encountered this particular -export-dynamic scenario, the program got native exception due to the wrong entry address. 
When looking back at the logs. I found this warning "cannot find entry symbol xport-dynamic; defaulting to XXXX". 

https://github.com/llvm/llvm-project/pull/72781


More information about the cfe-commits mailing list