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

No 'objectfile' build target available #5801

Open
keith-packard opened this issue Aug 15, 2019 · 2 comments
Open

No 'objectfile' build target available #5801

keith-packard opened this issue Aug 15, 2019 · 2 comments

Comments

@keith-packard
Copy link

keith-packard commented Aug 15, 2019

I'm building a C library, one of the installed files is 'crt0.o'. I didn't find a direct build target to construct this, but did manage to hack up executable() to work for now by adding flags to the link and compile arguments.

What I think would work is an 'objectfile' target which just took a single source file, along with
the usual compiler and install parameters.

For reference, here's how I'm calling executable for my use:

executable(crt_name,
	     srcs_picocrt,
	     include_directories : inc,
	     install : true,
	     install_dir : instdir,
	     c_args : value[1] + ['-fno-builtin', '-ffreestanding'],
	     link_args : value[1] + ['-r', '-ffreestanding', '-nostdlib'])

@jpakkane
Copy link
Member

For maximum control you might want to use a custom target, something like:

custom_target('crtobj',
    input: 'crt0.c',
    output: 'crt0.o',
    command: [meson.get_compiler('c'), '-c', '-o', '@OUTPUT@', '@INPUT@', ...],
    install: true,
    install_dir: ...)

Granted this may get a bit tricky if you have a lot of include dirs. An alternative approach is to build the target as a static library and then create a custom install script that installs the object file from the private directory.

And since you seem to be doing partial linking, you might be interested in #5499. Comments welcome.

@keith-packard
Copy link
Author

thanks, I'll experiment with this.

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