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

Explicitly disable pie when pie is false #4651

Open
yshui opened this issue Dec 18, 2018 · 8 comments
Open

Explicitly disable pie when pie is false #4651

yshui opened this issue Dec 18, 2018 · 8 comments
Labels

Comments

@yshui
Copy link
Contributor

yshui commented Dec 18, 2018

A lot of the platforms now has pie enabled by default, without any compiler flags. Maybe when the user explicitly set b_pie to be false, meson should explicitly disable pie with -no-pie.

@dcbaker dcbaker added the bug label Dec 18, 2018
@bwidawsk
Copy link

bwidawsk commented Dec 30, 2019

Is there any traction here?

Here is a test with pie: false

compile_commands.json: "command": "ccache cc -Ihello@exe -I. -I.. -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -MD -MQ 'hello@exe/main.c.o' -MF 'hello@exe/main.c.o.d' -o 'hello@exe/main.c.o' -c ../main.c",

And pie:true

"command": "ccache cc -Ihello@exe -I. -I.. -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fPIE -MD -MQ 'hello@exe/main.c.o' -MF 'hello@exe/main.c.o.d' -o 'hello@exe/main.c.o' -c ../main.c",

The only way I can get a statically linked, PIE is with something like the following:

project('test', 'c')
hello = executable('hello',
  'main.c',
  c_args: [ '-ffreestanding', '-static'],
  link_args: ['-nostdlib', '-static', '-Wl,--entry=main'],
  pie: false
)

This leads me to the conclusion that pie as an argument is actually broken as the above is required to make pie: false work correctly, and with those link args and cflags, pie: true still generates a no-pic executable.

Tagging @marc-h38

dcbaker added a commit to dcbaker/meson that referenced this issue Jan 6, 2020
Currently meson supports explicitly turning pie args on, but relies on
the default behavior being no-pie. This isn't always the case, and we
should explicitly add the correct no pie arguments.

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Jan 6, 2020
Currently meson supports explicitly turning pie args on, but relies on
the default behavior being no-pie. This isn't always the case, and we
should explicitly add the correct no pie arguments.

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Jan 6, 2020
Currently meson supports explicitly turning pie args on, but relies on
the default behavior being no-pie. This isn't always the case, and we
should explicitly add the correct no pie arguments.

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Jan 6, 2020
Currently meson supports explicitly turning pie args on, but relies on
the default behavior being no-pie. This isn't always the case, and we
should explicitly add the correct no pie arguments.

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Jan 6, 2020
Currently meson supports explicitly turning pie args on, but relies on
the default behavior being no-pie. This isn't always the case, and we
should explicitly add the correct no pie arguments.

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Jan 6, 2020
Currently meson supports explicitly turning pie args on, but relies on
the default behavior being no-pie. This isn't always the case, and we
should explicitly add the correct no pie arguments.

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Jan 8, 2020
Currently meson supports explicitly turning pie args on, but relies on
the default behavior being no-pie. This isn't always the case, and we
should explicitly add the correct no pie arguments.

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 14, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 14, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 14, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 21, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 24, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 25, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 25, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Mar 5, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Mar 5, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
dcbaker added a commit to dcbaker/meson that referenced this issue Mar 5, 2020
Currently meson assumes that you either want to force pie on, or get the
system default. Which is pretty silly as that is *not* what the
documentation suggests. This patch changes the pie args into a tristate,
["true", "false", "default"], where true means add pie on args, false
means add pie off args, and default means don't add any args. Default is
the default value for both -Db_pie and for the pie argument in
executable().

Fixes mesonbuild#4651
@mstorsjo
Copy link
Contributor

@dcbaker I see that you spent some effort on this early last year - any chance you might pick it up again? (I.e. +1, I also ran into this issue.)

@DidgeridooMH
Copy link

I also ran into this issue. What work is left to make this upstream?

@dcbaker
Copy link
Member

dcbaker commented Dec 23, 2021

I had patches that changed the behavior, but we wanted to make the behavior remain the same, ie, "nothing means add no flags and whatever the compiler defaults to" when you don't pass either true or false, and I never got around to fixing that. I've been in the midst of trying to make the interpreter argument handling more robust, and like several other changes here I've pushed this off until I can get that done, as it will make this work easier.

@dcbaker
Copy link
Member

dcbaker commented Dec 23, 2021

Also, we realized that pic has the same broken behavior, and needs to be fixed too.

@1ace
Copy link
Contributor

1ace commented Dec 23, 2021

I had patches that changed the behavior, but we wanted to make the behavior remain the same, [...], and I never got around to fixing that.

From what I can tell reading 9983262, it looks like you did do it 🙂

@marc-hb
Copy link

marc-hb commented Feb 3, 2023

From closed #6415:

too many conflicts, too hard to rebase. I'll just rewrite from scratch

I haven't found any rewrite.

@dcbaker
Copy link
Member

dcbaker commented Feb 3, 2023

I have patches, but they’re blocked on #10714

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

No branches or pull requests

7 participants