It's well known that continuous functions achieve minima on compact sets. An even stronger result is that lower semicontinuous functions achieve minima on compact sets.
Question. If an extended-real function $f$ attains a minimum on every compact subset of a topological space $X$, does it follow that $f$ is lower semicontinuous?
If it helps, I'm happy to assume that $X$ is a convex and compact subset of a locally convex TVS and that $f$ is convex.
What about the following function $f\colon\mathbb{R}\to\mathbb{R}$? $$ f(x) = \begin{cases} 0, & \text{if $x\neq 0$},\\ 1, & \text{if $x = 0$}. \end{cases} $$ It attains a minimum on every (compact) set, but it is not l.s.c.