Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.arlock
.depend
Make.dep
*.o
Expand All @@ -14,6 +13,7 @@ cscope.out
/Kconfig
/bin
/external
/.arlock
/.context
/.config
/.depend
Expand Down
4 changes: 2 additions & 2 deletions Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ $(CXXOBJS): %$(SUFFIX)$(OBJEXT): %$(CXXEXT)

.built: $(OBJS)
ifeq ($(WINTOOL),y)
$(call ARLOCK, "${shell cygpath -w $(BIN)}", $(OBJS))
$(call ARCHIVE, "${shell cygpath -w $(BIN)}", $(OBJS))
else
$(call ARLOCK, $(BIN), $(OBJS))
$(call ARCHIVE, $(BIN), $(OBJS))
endif
$(Q) touch $@

Expand Down
12 changes: 8 additions & 4 deletions Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CLEANDIRS := $(dir $(wildcard $(APPDIR)$(DELIM)*$(DELIM)Makefile))
CONFIGURED_APPS :=

define Add_Application
include $(1)Make.defs
include $(1)Make.defs
endef

$(foreach BDIR, $(BUILDIRS), $(eval $(call Add_Application,$(BDIR))))
Expand Down Expand Up @@ -99,9 +99,13 @@ define REGISTER
endef
endif

define ARLOCK
$(Q) flock .arlock $(call ARCHIVE, $1, $(2))
endef
# Workaround for concurrent execution to the same library (libapps)
ifeq ($(CONFIG_HOST_MACOS),y)
# macOS doesn't have flock. Use shlock instead.
AR := $(APPDIR)/tools/flock.sh $(APPDIR)/.arlock $(AR)
else
AR := flock $(APPDIR)/.arlock $(AR)
Copy link
Contributor

Choose a reason for hiding this comment

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

But I think this change still hit "@ can't find", I mention here:
apache/nuttx#342
since the symbol @ in side the original AR still pass to bash, but I can't understand why macOS no problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AR doesn't have @. ARCHIVE does.

Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Feb 21, 2020

Choose a reason for hiding this comment

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

But we can't bypass ARCHIVE and invoke AR directly, you can see there are mutiple ARCHIVE defintion in nuttx to fight or workaround the toolchain difference.
Actually, nuttx give the user freedom to provide own ARCHIVE defintion, so the ARCHIVE overload may exist more than we imagine.

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 checked some of ARCHIVE but they all seem calling AR one way or another.
you are right this doesn't work if ARCHIVE does something completely different.
i suspect it isn't the case though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is the case:
https://github.com/xiaoxiang781216/nuttx/blob/song-u1/arch/ceva/src/song/Toolchain.defs
You can see to support CEVA toolchain we have to do thing hard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i'm now convinced. thank you for the pointer.

endif

# Tools

Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ $(SYMTABOBJ): %$(OBJEXT): %.c

$(BIN): $(SYMTABOBJ)
ifeq ($(WINTOOL),y)
$(call ARLOCK, "${shell cygpath -w $(BIN)}", $^)
$(call ARCHIVE, "${shell cygpath -w $(BIN)}", $^)
else
$(call ARLOCK, $(BIN), $^)
$(call ARCHIVE, $(BIN), $^)
endif

endif # !CONFIG_BUILD_LOADABLE
Expand Down Expand Up @@ -198,7 +198,6 @@ else
fi; \
)
endif
$(call DELFILE, .arlock)
$(call DELFILE, .depend)
$(call DELFILE, $(SYMTABSRC))
$(call DELFILE, $(SYMTABOBJ))
Expand Down
36 changes: 36 additions & 0 deletions tools/flock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#! /bin/sh

# apps/tools/flock.sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# This script tries to mimic flock using shlock
#
# NOTE: It just aims to be enough for our usage in libapps build.
# Not intended to be a full replacement of flock.

LOCKFILE=$1
shift

while ! shlock -f ${LOCKFILE} -p $$; do
sleep 1
done

set -e
$@
STATUS=$?
rm -f ${LOCKFILE} || :
exit ${STATUS}