Hi Eran,
I finally fixed the gcc49 build, its log is just short of 10K lines i.e. REAL fun to diagnose
Btw I'm looking into gcc49 only to see if its regexes work so I can drop 3rd party implementations.
Until you mentioned it, I didn't consider caching while I wrote the script that inserts compiler-specific linker options:
Code: Select all
--[[
# add to linker options
$(shell $(LINK_CONF) $(ProjectName));
# define CL/global env vars
LINK_CONF=</absolute/path/to/linkopt.lua>
GCC49LIB_DIR=</absolute/path/to/lib64/dir>
# add to post-build commands (optional)
ldd $(OutputFile) | grep -E '\blibstdc++'
]]
local wd = os.getenv("PWD")
f= io.open("wrap_link.log", "w")
assert(f)
f:write("LUA WD = "..tostring(wd).."\n\n")
---- print any arguments -------------------------------------------------------
local n_args = #arg
f:write("\nlua args: ", n_args, "\n")
if (0 == n_args) then
f:write("MISSING ARGUMENTS, aborting")
-- ERROR
return
end
for k, v in ipairs(arg) do
f:write(("\targ[%d] = %s\n"):format(k, tostring(v)))
end
f:write("\n\n")
local ProjectName = arg[1]
---- ENV VARS ------------------------------------------------------------------
f:write("\n\nENV VARS:\n")
-- get shell env vars in one go
local env_s = io.popen("env"):read("*a")
f:write(env_s, "\n\n")
-- get CL env var of gcc4.9 library dir
local lib_dir = os.getenv("GCC49LIB_DIR")
f:write("lib_dir: ", tostring(lib_dir), "\n\n")
---- read CL's pre-saved MAKE file ---------------------------------------------
local mk_s
do
local ProjectMkFilename = ProjectName .. ".mk"
local proj_f = io.open(ProjectMkFilename)
mk_s = proj_f:read("*a")
proj_f:close()
end
---- GCC49 CL env vars from MAKE file ------------------------------------------
f:write("\nEXTRACTED:\n")
local link_s = mk_s:match("LinkerName%s+:=(.-)\n")
f:write("linker: "..tostring(link_s), "\n")
local pat = link_s:match("(g%+%+49)$")
f:write("link pat: "..tostring(pat), "\n")
local ret = ''
-- runtime output should look like this
-- "-Wl,-rpath,/home/plaufenb/development/gcc49/lib64"
-- i.e. replace semicolons with spaces
if (pat) then
-- explicit link not needed?
-- ret = '-Wl,-rpath,'..lib_dir..' -lstdc++ '
ret = '-Wl,-rpath,'..lib_dir..' '
else
-- nop
ret = ' '
end
f:write("ret: \""..tostring(ret), "\"\n")
f:close()
-- will get inserted into linker cmd
print(ret)
it's kindof a hack; some vars are explicit arguments, others are fetched from system env vars and others from the project.mk file CL generates.
I figured that any variables written to the make file when my script gets called can no longer be changed. Is it somehow related to caching?
Do you have some dependency graph (even scribbled on a napkin) indicating what is checked and in which order? F.ex. whether the project env vars are applied before pre-build commands or when a selected compiler change is checked / what other stages it invalidates?
thx & cheers,
-- p
edit: sory my 1st question was unclear