Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:13:29+00:00 2026-06-16T17:13:29+00:00

I am using GNU make , where I have a top level makefile ,

  • 0

I am using GNU make, where I have a top level makefile, which invokes
another makefile, for different types of builds, like:

LIST_OF_TYPES: 32 64 ...

tgt-name: deps
          $(foreach i,$(LIST_OF_TYPES), \
            $(MAKE) -f $(MY_MAKEFILE) ARCH=$i mylib;)

when running with higher j factor like -j100 etc, one of the build fails, but
the return value is still 0 so, I cannot make out if the build really did work!
Is there anything wrong with the way I’m using the foreach construct?
or its just the higher j with foreach which is causing problems?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:13:31+00:00Added an answer on June 16, 2026 at 5:13 pm

    I’ve never seen this kind of use of foreach, but it seems to work for you. Usually I use a bash for loop

    tgt-name: deps
        for i in $(LIST_OF_TYPES); do $(MAKE) -f $(MY_MAKEFILE) ARCH=$$i mylib; done
    

    But this is not the problem, since in either case the makes are run sequentially, AFAICS.

    Since you build a library, there’s the possible clash of two objects being inserted into an archive simultaneously. When this happens the archive might become corrupted.

    As with every parallel execution, be it make jobs or threads, you must protect the shared resources (the archive in your case). You must add the objects at the end of the library build or protect the insertion with some lock (e.g. man lockfile or similar).

    There might be other problems, of course. Look out for the simultaneous access to shared resources (object files, archives, …) or incomplete defined dependencies.

    Update:

    foreach seems not to be a problem. Set LIST_OF_TYPES to a single type (e.g. 32 only) and then do a make -j100 mylib. If the problem is with the building of a single archive, it will fail with only one type as well.

    You can also test with make ARCH=32 -j100 mylib. This should show the problem too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C++ small project using GNU Make. I'd like to be able
I'm using GNU Make 3.81, and I have the following rule in my Makefile:
I am new to using GNU make. I have a makefile as below: CFLAGS
I'm using GNU Make to build three different editions of a static html document.
Note: using MinGW's make (should be GNU make) i have a couple of -include
I am using gnu Make 3.82 and have an annoying problem. I have a
I have a C++ based project(many source files) compiled using gnu make via a
I usually have an environment setting for MAKE_MODE (Windows XP, using GNU make, both
I am using a GNU Make Makefile to build a C project with several
Using GNU's make, I'd like to extract the first character of a variable. Currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.