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

Simpify component startup by removing component_entry_point lib #2199

Closed
nfeske opened this issue Dec 15, 2016 · 3 comments
Closed

Simpify component startup by removing component_entry_point lib #2199

nfeske opened this issue Dec 15, 2016 · 3 comments
Labels

Comments

@nfeske
Copy link
Member

nfeske commented Dec 15, 2016

Right now, our component-startup procedure provides several hooks to cover a large diversity of components:

  • Modern Genode components that use the component API,
  • Legacy Genode components that still have a main function,
  • POSIX applications that use libc and have a main function,
  • Genode components that depend on libc but also provide a Genode service and thereby use the component API, and
  • Hybrid Linux/Genode components.

The hooks make the startup arguably more complex than it should be. One particular case is the hook that we provide for the libc to customize the runtime environment of a libc-using program. Such programs tend to use blocking I/O (read, select), which does not fit well with the asynchronous nature of the component API. Under the hood, the libc bridges this semantic gap by the means of user-level scheduling. To implement this, it needs to intercept the startup of the application code.

Long story short, when linking against the libc, Component::construct is transparently intercepted by the libc. With this issue, I suggest to drop the "transparently" part and make the interception explicit. In order to use both Genode's component API and libc I/O functions, a component should implement a Libc::Component::construct function. The libc would provide the implementation of the regular Component::construct function by setting up the context of the application code and finally calling the application-provided Libc::Component::construct.

@nfeske nfeske added the cleanup label Dec 15, 2016
@nfeske
Copy link
Member Author

nfeske commented Dec 15, 2016

As an intermediate step, it would be good to remove the category of "legacy Genode components that still have a main function" by replacing main with a Component::construct. This way, we can drop the distinction of both cases as currently done by component_construct.cc.

@chelmuth
Copy link
Member

To bridge the gap between the libc component approach and POSIX programs, we should implement a libposix.lib.so that implements Libc::Component::construct and calls main. This library is also the right place to handle the environment variables and command-line arguments. So, we'd finally supersede the config_args library and provide <env name="..." value="..."/> and <arg value="..."/> as configuration nodes of <libc>.

nfeske added a commit to nfeske/genode that referenced this issue Dec 23, 2016
This patch removes the component_entry_point library, which used to
proved a hook for the libc to intercept the call of the
'Component::construct' function. The mechansim has several shortcomings
(see the discussion in the associated issue) and was complex. So we
eventually discarded the approach in favor of the explicit handling of
the startup.

A regular Genode component provides a 'Component::construct' function,
which is determined by the dynamic linker via a symbol lookup.
For the time being, the dynamic linker falls back to looking up a 'main'
function if no 'Component::construct' function could be found.

The libc provides an implementation of 'Component::construct', which
sets up the libc's task handling and finally call the function
'Libc::Component::construct' from the context of the appllication task.
This function is expected to be provided by the libc-using application.
Consequently, Genode components that use the libc have to implement the
'Libc::Component::construct' function.

The new 'posix' library provides an implementation of
'Libc::Component::construct' that calls a main function. Hence, POSIX
programs that merely use the POSIX API merely have to add 'posix' to the
'LIBS' declaration in their 'target.mk' file. Their execution starts at
'main'.

Issue genodelabs#2199
nfeske added a commit that referenced this issue Dec 28, 2016
This patch removes the component_entry_point library, which used to
proved a hook for the libc to intercept the call of the
'Component::construct' function. The mechansim has several shortcomings
(see the discussion in the associated issue) and was complex. So we
eventually discarded the approach in favor of the explicit handling of
the startup.

A regular Genode component provides a 'Component::construct' function,
which is determined by the dynamic linker via a symbol lookup.
For the time being, the dynamic linker falls back to looking up a 'main'
function if no 'Component::construct' function could be found.

The libc provides an implementation of 'Component::construct', which
sets up the libc's task handling and finally call the function
'Libc::Component::construct' from the context of the appllication task.
This function is expected to be provided by the libc-using application.
Consequently, Genode components that use the libc have to implement the
'Libc::Component::construct' function.

The new 'posix' library provides an implementation of
'Libc::Component::construct' that calls a main function. Hence, POSIX
programs that merely use the POSIX API merely have to add 'posix' to the
'LIBS' declaration in their 'target.mk' file. Their execution starts at
'main'.

Issue #2199
nfeske added a commit to nfeske/genode-world that referenced this issue Dec 28, 2016
This patch adapts the world components according to the following issue:

  genodelabs/genode#2199
nfeske added a commit to nfeske/genode-world that referenced this issue Dec 28, 2016
This patch adapts the world components according to the following issue:

  genodelabs/genode#2199

Fixes genodelabs#57
nfeske added a commit that referenced this issue Jan 13, 2017
This patch removes the component_entry_point library, which used to
proved a hook for the libc to intercept the call of the
'Component::construct' function. The mechansim has several shortcomings
(see the discussion in the associated issue) and was complex. So we
eventually discarded the approach in favor of the explicit handling of
the startup.

A regular Genode component provides a 'Component::construct' function,
which is determined by the dynamic linker via a symbol lookup.
For the time being, the dynamic linker falls back to looking up a 'main'
function if no 'Component::construct' function could be found.

The libc provides an implementation of 'Component::construct', which
sets up the libc's task handling and finally call the function
'Libc::Component::construct' from the context of the appllication task.
This function is expected to be provided by the libc-using application.
Consequently, Genode components that use the libc have to implement the
'Libc::Component::construct' function.

The new 'posix' library provides an implementation of
'Libc::Component::construct' that calls a main function. Hence, POSIX
programs that merely use the POSIX API merely have to add 'posix' to the
'LIBS' declaration in their 'target.mk' file. Their execution starts at
'main'.

Issue #2199
ehmry pushed a commit to ehmry/genode-world that referenced this issue Jan 19, 2017
This patch adapts the world components according to the following issue:

  genodelabs/genode#2199

Fixes genodelabs#57
nfeske added a commit to genodelabs/genode-world that referenced this issue Jan 19, 2017
This patch adapts the world components according to the following issue:

  genodelabs/genode#2199

Fixes #57
@nfeske
Copy link
Member Author

nfeske commented Feb 28, 2017

Fixed in Genode 17.02

@nfeske nfeske closed this as completed Feb 28, 2017
nfeske added a commit that referenced this issue Jun 28, 2023
Besides the removal of the legacy 'main' support, this patch simplifies
the lib/startup/_main.cc.

Issue #2199
chelmuth added a commit to genodelabs/genode-world that referenced this issue Jun 29, 2023
nfeske added a commit that referenced this issue Jul 14, 2023
Besides the removal of the legacy 'main' support, this patch simplifies
the lib/startup/_main.cc.

Issue #2199
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

2 participants