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

[dv,sw] Makefile refactor #230

Merged
merged 1 commit into from
Sep 25, 2019
Merged

[dv,sw] Makefile refactor #230

merged 1 commit into from
Sep 25, 2019

Conversation

sriyerg
Copy link
Contributor

@sriyerg sriyerg commented Sep 20, 2019

  • added centrallized Makefile infra for maximizing reuse across SW
    test, lib and boot_rom targets
  • existing Make flows still remain (for the timebeing; will remove it
    once all approve of this)
  • all make commands are to be run from sw/ area
  • TODOs
  • add some documentation
  • fix support for external apps, eg coremark
  • find better way for adding .c -> .o and .c -> .ppo recipes
  • move boot_rom image gen and sw lib gen to SV build step so that it is not executed per test

@sriyerg sriyerg changed the title [dv,sw] sw Makefile refactor [dv,sw] Makefile refactor Sep 20, 2019
sw/opts.mk Outdated Show resolved Hide resolved
hw/dv/tools/rules.mk Outdated Show resolved Hide resolved
@moidx
Copy link
Contributor

moidx commented Sep 20, 2019

Hi @sriyerg, for reference #201 is the Meson build system implementation we have been discussing.

sw/Makefile Outdated Show resolved Hide resolved
sw/opts.mk Outdated Show resolved Hide resolved
SW_BUILD_DIR ?= $(SW_ROOT_DIR)/$(SW_DIR)

LIB_NAME ?= ot
LIB_TARGET ?= $(LIB_BUILD_DIR)/lib${LIB_NAME}.a

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we allow the individual lib*/srcs.mk to add to this variable? I'm envisioning in the future if we have multiple libs we need to create, it would be nice to only have to modify the sw/Makefile only for the new includes, and have everything else just work out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, any / all srcs.mk files can append more targets to LIB_TARGET to add more custom targets if needed. Might have to make some fixes to the rules though, but it could definitely work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm, probably not a high priority for now :) Maybe if the readme just has a comment on how this could be done that would be more than enough.


# SW_OPTS are options for SW apps that come with their own Makefile (example coremark)
CL_SW_OPTS +=
SW_OPTS += ${CL_SW_OPTS}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this one consumed by the sw_build step?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SW_OPTS are Makeflags for external apps such as coremark which have its own Makefile. SW_FLAGS are compiler flags we can pass to our own local sw. Both are consumed by sw_build step.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah that makes sense. but i don't see SW_OPTS used anywhere though.
Speaking of which, the coremark case doesn't seem to quite work right now (at least in my trial). Looks like the LIB_DIR variable isn't passing on correctly, it could just be my environment. I haven't looked too closely.

I won't comment too much more on this for now, i'll try to digest the meson usage, since both you and Miguel say that's better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the hw/dv/tools/rules.mk to set Makeflags to SW_OPTS, so it should now work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

# compile sw sources
# TOOD: figure out a way to 'templatise' .o/.ppo ruleset for each dir containing srcs

$(SW_BUILD_DIR)/%.o: $(SW_DIR)/$$*.c

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this one, i think @eunchan does something like it in his private repo makefile where he assumes there are multiple 'tops'.

Might be good to reference that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry not multiple tops, multiple IPs.

@tjaychen
Copy link

tjaychen commented Sep 20, 2019 via email

@tjaychen
Copy link

this LGTM overall, but I guess you're still working on adding more things?

Let me know if it's ready for final approval and you want to finish the rest off in a different PR.

Copy link

@tjaychen tjaychen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@moidx
Miguel could you scan through quickly? I know we may change this to meson later, but just wanted to make sure there isn't anything that really stands out to you.

@sriyerg
I just realized we'll probably need to follow on with another PR quickly to change all the documented instructions, since right now they all go to the actual directory (for example boot_rom) to build.

Could you actually file an issue on that and maybe have it as a P0 or P1 so we don't forget?

@sriyerg
Copy link
Contributor Author

sriyerg commented Sep 23, 2019

LGTM

@moidx
Miguel could you scan through quickly? I know we may change this to meson later, but just wanted to make sure there isn't anything that really stands out to you.

@sriyerg
I just realized we'll probably need to follow on with another PR quickly to change all the documented instructions, since right now they all go to the actual directory (for example boot_rom) to build.

Could you actually file an issue on that and maybe have it as a P0 or P1 so we don't forget?

Filed issue #244 for updating the SW commands in documentation. I will work on it once this PR is merged.

Copy link
Contributor

@moidx moidx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple fo nit comments. Also, can you squash some of the changes or modify the commit descriptions so that they have enough details once submitted? Squash and merge is not supported in this repo.

Also, It'd be nice if you remove the old Makefiles after updating the documentation.

Thanks!

@@ -7,6 +7,7 @@

#include "common.h"
#include "flash_ctrl.h"
#include "flash_ctrl_regs.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed in #228. Can you rebase and revert this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

sw/rules.mk Outdated
# SPDX-License-Identifier: Apache-2.0
#
##########################################################################
## The following variables must be set prior to invoking this Makefile ##
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these comments still accurate? If not, can you remove it and add a comment describing what should go here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks.

@tjaychen
Copy link

i actually thought Sri removed all the old makefiles already. It was one of the things we discussed earlier today.

@moidx
Copy link
Contributor

moidx commented Sep 24, 2019

i actually thought Sri removed all the old makefiles already. It was one of the things we discussed earlier today.

The deletion was done in a separate commit within this PR. My suggestion to delete later is based on the fact that after we merge these changes the documentation will be broken. It is always preferred to keep the repo in green state at the commit level, so that it is easier to maintain the history.

It is not a big deal right now, but we should start thinking about staging things this way to avoid running into maintenance issues later.

@tjaychen
Copy link

ah yeah, Sri and I talked about that also. He actually opened an issue already to follow on with another PR to fix the documentation. I mostly favored removing the old makefiles because it would probably cause quite a bit confusion having them both there.

[sw] Makefile refactor

- added centrallized Makefile infra for maximizing reuse across SW
test, lib and boot_rom targets
- existing Make flows still remain (for the timebeing; will remove it
once all approve of this)
- all make commands are to be run from sw/ area
- updated with chip_info generation
- TODOs
  - add some documentation
  - need to fix support for external apps, eg coremark

[dv,sw] coremark port now works

- updates to get external app (coremark) compiling with the refactored
flow
- added ability to compile targets with external Makefiles with
STANDALONE_SW var
- added sw/benchmarks/srcs.mk to supply STANDALONE_CMD to build custom
app

[dv,sw] removed existing Makefiles (deprecated)
Copy link
Contributor Author

@sriyerg sriyerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@moidx
Miguel could you scan through quickly? I know we may change this to meson later, but just wanted to make sure there isn't anything that really stands out to you.

@sriyerg
I just realized we'll probably need to follow on with another PR quickly to change all the documented instructions, since right now they all go to the actual directory (for example boot_rom) to build.

Could you actually file an issue on that and maybe have it as a P0 or P1 so we don't forget?

I work on doc as a part of another PR - I am dependent on this one for msging flow updates.

sw/rules.mk Outdated
# SPDX-License-Identifier: Apache-2.0
#
##########################################################################
## The following variables must be set prior to invoking this Makefile ##
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks.

@sriyerg sriyerg requested a review from moidx September 25, 2019 01:37
Copy link
Contributor

@moidx moidx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for working on this @sriyerg

@sriyerg sriyerg merged commit 789c27c into lowRISC:master Sep 25, 2019
@sriyerg sriyerg deleted the top_dv branch September 25, 2019 03:42
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

Successfully merging this pull request may close these issues.

None yet

3 participants